Skip to content
marick edited this page Jan 16, 2013 · 21 revisions

This covers version 3.x+ of lein midje, which only runs under Leiningen 2 and Midje 1.5.X+. For information on older versions, see the lein-midje project page or use lein help midje.

The basic lein midje options were covered in command-line tools. They are:

% lein midje                        # Check facts in source and test namespaces
% lein midje proj.ns-1 proj.ns-2    # Check facts in selected namespaces
% lein midje proj.subproj.*         # Check facts in a subtree of namespaces

% lein midje :autotest              # Check all facts once; recheck changed namespaces.

lein midje has further options. Options have Clojure keyword syntax. (Thus, :autotest is an option.) When options take arguments, they are all the following tokens, up to the next option or the end of the arguments.

Common options

:config

The arguments are pathnames that override Midje's default configuration files. Here's an example:

% lein midje :config /Users/marick/alternate-config configs/integration

Notes:

  • Pathnames are relative to the root of the project directory.
  • Config files are read in left to right order.
  • The default config files are not read when the :config option is given.

As a result of the last, :config with no arguments means that Midje reads no config files.

:autotest

Autotest works in terms of directories full of Clojure files, not namespaces. You can limit which directories it considers by giving it specific directories:

% lein midje :autotest test/midje/util src/midje/util

Notes:

  • Pathnames are relative to the project's root.
  • Changes do not propagate "through" unmentioned directories. For example, suppose that the test namespace midje.util.t-final depends on source namespace midje.emission.api, which itself depends on source namespace midje.util.ecosystem. A change to midje.util.ecosystem would not cause the facts in midje.util.t-final to be rechecked because src/midje/emission is not being watched for changes.
  • There is no way to point :autotest at individual files.

Options without :autotest

Midje facts have metadata that allows you to tag them with arbitrary information. Here are three examples:

(fact "this is an ordinary test" ...)
(fact "this is a core test" :core ...)
(fact "this is a slow test" :slow ...)
(fact "this is a slow core test" :core :slow ...)

The :filter option allows you to restrict which facts in the already-selected namespaces are run. For example, to check the core facts in all the namespaces, you'd use:

% lein midje :filter core

To run the core tests in only the utility directory, you'd use:

% lein midje utility.* :filter core

Filter terms can be negated by preceding them with -. Here is how you'd check all the facts that aren't marked as slow:

% lein midje :filter -slow

When there is more than one filter term, facts that match any of them are run. For example, the following runs all the fast (not :slow) tests, but runs core tests even if they're slow.

% lein midje :filter -slow core
Clone this wiki locally