I’ve changed testing libraries for my Clojure code. When I first started writing tests for Clojure code, I settled on expectations, which was written by Jay Fields. The syntax and structure seemed natural enough, and I was a content with my choice.

Then I started building an application atop the Immutant application server. Immutant is a project sponsored by RedHat, and is essentially a set of libraries laid over JBoss to enable Clojure developers to target JBoss for deployment in a way that feels very natural. Working with Immutant meant using the lein-immutant plugin for leiningen. lein-immutant supports running tests against a running Immutant server, but the plugin does not support expectations among its test options. This left me with a choice to make between clojure.test and Brian Marick’s midje. While its syntax is somewhat quirky in the context of Clojure, I settled on midje. After porting a handful of tests from expectations to midje, I proceeded to create well over 100 test cases with midje, and am satisfied with the library at this point. When executed against my running application in a repl attached to the application, the entire test suite executes in less than 2 seconds, which is an acceptable timeframe for me.

I’m still working on getting autotest to operate the way I want it to when targeting Immutant, but I’m glad to at least have a functioning test suite.