Skip to content
marick edited this page Jan 18, 2013 · 2 revisions

Print levels are available in Midje 1.5+

The verbosity of Midje's output can be controlled in several ways. They all use Midje's print levels. The default print level is :print-normally. There are levels below it:

  • :print-no-summary (-1)

    This causes Midje to omit its normal summary message, which otherwise looks like this:

    All claims (17) have been confirmed.
    
  • :print nothing (-2)

    There is no output. However, Midje still keeps track of pass/fail counts. You can see whether a fact fails by checking whether it returned true or false. Repl functions like load-facts and check-facts process a stream of facts. They return a small map with the number of failures: {:failures 23}.

There are also more verbose print levels:

  • :print-namespaces (1)

    Whenever a fact in from a new namespace is about to be checked, Midje prints information like this:

    = Namespace midje.parsing.t-arglists
    
  • :print-facts (2)

    This prints the doc string of facts before they're checked:

    Checking eagerly doesn't barf on sorted-sets with custom comparators... See issue: #158
    

    If there is no doc string, the file and line number are printed.

Each symbolic (keyword) print level is associated with an integer. You can use that integer wherever a print level is called for. So, if you like shorthand, you can speak of "print level 2" instead of :print-facts.

Setting print levels

You can set a print level in a configuration file. This is the appropriate command:

(change-defaults :print-level :print-namespaces)

You can also dynamically wrap a section of code with a print level:

(require '[midje.config :as config])
(config/at-print-level :print-facts
  ...some facts here...)

Many of the repl tools take a print-level argument:

(load-facts 'namespace :print-facts)
Clone this wiki locally