Friday, July 16, 2010

Better Clojure Test Results on the Command Line

After letting folks know about Deview earlier this week, some people thought that a command line tool that improved test results would be a better fit for them. Deview has some features that you can't have in a command line tool, and more are planned for the future. However, I can see the value in having a simple tool that does one thing well. Even though I plan to use and continue to improve Deview, I took a day off and created lein-difftest.

lein-difftest is a completely new project that does not depend on Deview. It depends on many of the same libraries as Deview but is much simpler. It may be used as a Leiningen plugin or from the REPL.

To use it from Leiningen you simply add lein-difftest as a dev-dependency. See lein-difftest for more information. Once you have this new library in place, run lein test and you will see the new and improved results. The example below shows two test runs. One without lein-difftest and the other with.



To use it from the REPL there is a helper function named test-ns with takes care of reloading the target namespace and turning off color.


user> (use 'difftest.core)
user> (test-ns 'some.test.namespace)


Robert Hooke


This project is also a great example of using Robert Hooke to extend Leiningen. Before using Hooke, I had to copy the entire leiningen.test/test function into my plugin code so that I could modify one of its function calls. With Hooke, I simple intercept the call to said function and ensure that it has the correct arguments.

1 comment:

  1. I really really like this plugin. Thanks!

    ReplyDelete