views:

458

answers:

4

What is the best unit testing framework for Clojure?

I prefer a more BDD style framework.

Thanks, Alex

+6  A: 

Stuart Halloway, author of the Programming Clojure book, is currently working on Circumspec, advertised as "BDD in Clojure" in the README. This is a work in progress, but perhaps may be what you're looking for. There's also Conducta, which is apparently meant to enable BDD in Clojure with some funny syntax.

(Updated this paragraph in response to Stuart Sierra's comment below.) Out of the box, Clojure provides clojure.test and clojure.test.junit namespaces. The former is a Clojure specific framework, while the latter generates JUnit-style XML reports based on clojure.test's output. There's a successor to clojure.test in the works currently, but it's very usable as it stands now.

Finally, since I understand (from your previous question) that you're just starting out with the language, I'll add that if there's some testing framework you especially like and it's available on the JVM, there's a good chance that writing a wrapper in Clojure may not be too much of a problem. Or you can just write "Java in Clojure" and use Javaish idioms directly with no wrappers at all. Clojure's Java interop is excellent.

Michał Marczyk
Correction: clojure.test.junit only generates JUnit-style XML reports from clojure.test; it is not a JUnit integration library.
Stuart Sierra
Thanks for the comment, Stuart! I'll edit the answer straight away.
Michał Marczyk
+6  A: 

I wrote clojure.test, and I am working on a new framework, lazytest, with a more functional style.

Stuart Sierra
Can't wait to do QuickCheck-style testing in Clojure with lazytest! Thanks a lot for all your contributions.
Michał Marczyk
+1  A: 

I'm working on a mock-oriented, top-down testing framework. It'll have three levels of abstraction. The first two are finished: http://github.com/marick/Midje#readme I'm working on the top level, which will look something like what's shown in the following comment.

Brian Marick
A: 

Here's the other link, which I as someone not in the stackoverflow ecosystem couldn't post:

this: http://www.exampler.com/blog/2010/06/10/tdd-in-clojure-a-sketch-part-1/

Brian Marick