Search code examples
clojuremidjeclojure-testing

Is there an equivalent of Midje facts form in clojure.test?


(facts ...) form in Midje, let's us group a bunch of (fact ..) forms and also have more (facts ..) form under it.

When writing corresponding test suite in clojure.test, what should be used to replace, (facts ...) ? Is there something else in clojure with similar semantics ?


Solution

  • You can use testing to group your tests. Paraphrased example from the linked doc page:

    (deftest arithmetic
      (testing "with positive integers"
        (is (= 4 (+ 2 2)))
        (is (= 7 (+ 3 4))))
      (testing "with negative integers"
        (is (= -4 (+ -2 -2)))
        (is (= -1 (+ 3 -4)))))