Skip to content
marick edited this page Nov 28, 2014 · 4 revisions

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 checks (17) succeeded.
    

    That is, the only output will come from checkable failures.

  • :print nothing (-2)

    There is no output, even for failures. However, Midje still keeps track of failures. You can get that information in three ways:

    • Facts return false if any of their checkables failed; true otherwise.
    • 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}.
    • Lein-midje exits with a non-zero status in the case of failures.

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 description of a fact before it's checked. (This is the same description as is printed in case of failure.) If there is no description, 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