Introduction to testing with expectations/clojure-test and humane-test-output

There are lots of ways to improve on the default the testing experience in Clojure. I put together a tutorial post on a complete testing experience I’m using. The most important libraries are expectations/clojure-test and humane-test-output which together give you concise, readable tests with great output. As expectations/clojure-test is compatible with the standard clojure.test we can use other standard tools (for example any test runner).

What testing libraries are you using, why? What test runner do you use? Any tips for testing in Clojure?

1 Like

Very cool to see someone writing about the clojure.test-compatible version of Expectations! Thank you.

Two possibilities for your >= 5 test:

user=> (defexpect digit-test
         (expecting "Expecting 5 to be a larger number"
           (expect (>= 5 (+ 1 9)))))
user=> (digit-test)

FAIL in (digit-test) (NO_SOURCE_FILE:3)
Expecting 5 to be a larger number
expected: (>= 5 (+ 1 9))
  actual: (not (>= 5 10))
user=> (expect (partial >= 5) (+ 1 9) "Expecting 5 to be a larger number")

Expecting 5 to be a larger number
expected: (=? (partial >= 5) (+ 1 9))
  actual: (not ((partial >= 5) 10))