Code Coverage of Clojure Code

Published: 8:04 PM GMT+12, Friday, 24 April 2009 under: technology
testing  java  functional  coverage  development  clojure  github  git  maven 

Since pulling in Dmitry's test-compile mojo, and adding a test script runner mojo to the clojure-maven-plugin I thought I'd try something fun like running the maven emma plugin against a very simple test project.

I was pleasantly surprised to see some fairly useful (ish) coverage data come back:

You can easily see coverage information for your code, even if you end up trying to decipher clojures generated class names. You even get fairly useful breakdown on the class detail, even if there's only the one method on each class:

Once you've installed the clojure-maven-plugin, simply configure the plugin in your pom.xml:

After defining which namespaces you wish to compile, and which script to use as your starting test script, bind the plugin to both the compile and test phases (it would be nice if the plugin handled this automatically, but I'm not sure its possible) and call "mvn emma:emma" for your very own coverage report.

Adding these simple automated compile, test, and coverage processes to a clojure's impressive arsenal clojure already offers gives me a greater level of trust to experiment and use the young language in projects destined for a production environment.

Comments (0)

Add Comment