Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
lein midje options were covered in lein-midje basics. 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.
The arguments are pathnames that override Midje's default configuration files. Here's an example:
% lein midje :config /Users/marick/alternate-config configs/integration
- 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
:configoption is given.
As a result of the last,
:config with no arguments means that Midje reads no config files.
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
- Pathnames are relative to the project's root.
- Changes do not propagate "through" unmentioned directories. See the autotest page for an explanation and an example.
- There is no way to point
:autotestat individual files.
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 ...)
: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 autotest all the facts that aren't marked as slow:
% lein midje :autotest :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 :filters -slow core
:filters is a synonym for
This "match any" interpretation of
:filter can be confusing in cases like this:
(fact :agent :agent => :failed) (fact :integration :integration => :failed) (fact :passes => truthy)
Suppose you want to run only the fact that's neither
:integration. The temptation is to do it like this:
% lein midje :filter -integration -agent
That, however, still runs all three of the tests. The first is run because it's not
:agent, the second because it's not
:integration, and the third because it's not either. There's no way to get the behavior you want on the command line. For this, and for more complicated situations, use configuration files. Put the following in a file like
(change-defaults :fact-filter #(and (not (:agent %)) (not (:integration %))))
lein midje like this:
$ lein midje :config fast.config