lein-difftest is a Leiningen plugin for running clojure.test
tests. It works exactly the same as lein test but with alternate test reporting. When a test fails, the report shows the diff of the actual and expected forms. When a test fails due to an error, stacktraces are cleaned up with clj-stacktrace.
The screenshot below shows two test runs. The first run shows the normal output when running lein test without this plugin. The second run shows output for the same tests after this library has been installed.
The summary lines at the bottom are color coded: red means there was an error in one or more tests, yellow means that there were no errors but there were failures in one or more tests and green means that all tests pass.
Add to your ~/.lein/profiles.clj file:
{:user {:plugins [[lein-difftest "2.0.0"]]}}
…and then you should be able to run lein difftest in any project.
Users of Leiningen 1.x can install an older version like so:
$ lein plugin install lein-difftest 1.3.7
Add it to init.clj:
(try (require 'leiningen.hooks.difftest)
(catch java.io.FileNotFoundException _))
user> (use 'difftest.core)
user> (activate)
user> (test-ns 'some.test.namespace)
difftest.core/test-ns
may be passed 0 or more namespaces. In the 0 case, it will run tests in the current namespace *ns*
. Additionally, it will load or reload the namespaces that it is passed. Finally, it will disable the color feature as this does not look very nice in some REPLs. If you like color in the REPL then you can use difftest.core/run-tests
.
If you would like to see a quick example of what test failures and errors look like, or if you would like to experiment with or improve this library, enter the following commands:
$ git clone git://github.com/brentonashworth/lein-difftest.git
$ cd lein-difftest
$ lein test
All of the tests fail so that you may see examples of exceptions, and various diffs.
Apart from Clojure, clojure.test and Leiningen, lein-difftest is built on top of other fine libraries:
Copyright © 2010-2011 Brenton Ashworth
Thanks to George Jahad for the idea and the work on difform, Phil Hagelberg for wanting a command line version of Deview and for contributions by Paul Stadig.
Distributed under the Eclipse Public License, the same as Clojure uses. See the file COPYING.