Skip to content
marick edited this page Apr 25, 2012 · 4 revisions

Midje can be used with leiningen's test plugin. You can wrap facts in either deftest or with-test:

(deftest one-fact-in-a-test
  (fact (+ 1 1) => 3))

(with-test
  (defn foo [x y] (* x y))
  (fact (foo 1 2) => 3))

The output looks as you'd expect if you were using clojure.test:

Testing lein-test.test.deftest
FAIL at (deftest.clj:10)
Expected: 4
  Actual: 3
FAIL at (deftest.clj:11)
Expected: 4
  Actual: 5
FAIL at (deftest.clj:7)
Expected: 3
  Actual: 2
Testing lein-test.test.with-test
FAIL at (with_test.clj:8)
Expected: 3
  Actual: 2
Ran 3 tests containing 4 assertions.
4 failures, 0 errors.

The summary lein test prints won't contain information about Midje failures. Therefore, I recommend you use the lein midje plugin.

Clone this wiki locally