Lein midje basics

Matt Freeman edited this page Sep 27, 2015 · 3 revisions
Clone this wiki locally

First install lein-midje in your .lein/profiles.clj file:

{:user {:plugins [[lein-midje "3.0.0"]]}}

To check everything:

% lein midje

That checks all facts and clojure.test tests in your project's :test-paths and :source-paths. (Midje users sometimes add facts to their source as documentation.) You can also name one or more specific namespaces:

% lein midje implementation.t-line-number-reporting user.checkers.t-collection

You can also use * to abbreviate multiple namespaces:

```bash` % lein midje implementation.emission.*


Note that `*` names a whole namespace subtree. That is, the previous command will check both `implementation.emission.t-api` and `implementation.emission.plugins.t-default`. 


`lein midje` checks both clojure.test tests and Midje facts. It shows output like this:

![output](https://raw.github.com/marick/midje-clojure-test-tutorial/master/images/2.jpg)

The exit status is the count of clojure.test and Midje failures (up to a maximum of 255). That is, you can check for batch command success or failure in the usual Unixey way.

---------------

Lein-midje can also be used to [[autotest]]. In that mode, it watches for file changes and reloads affected files (typically rechecking facts). Here's an example:

![autotest output](https://raw.github.com/marick/midje-clojure-test-tutorial/master/images/3.jpg)