Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Leiningen plugin for running tests with better error reporting
Clojure
branch: master

This branch is 36 commits behind brentonashworth:master

README.textile

lein-difftest

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.

If used as a plugin, Leiningen 1.2 or greater is required. It will work from the REPL with any version of Clojure.

Note: If your project depends on Clojure 1.2 but not Contrib 1.2 then you will need to add Contrib 1.2 as a dependency. clj-stacktrace depends on Contrib 1.1. This version of Contrib will be added to your project if you don’t already have a dependency on Contrib. Contrib 1.1 and Clojure 1.2 do not work together.

See It

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.

lein-difftest

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.

Try It

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 deps
$ lein test

All of the tests fail so that you may see examples of exceptions, and various diffs.

Leiningen Usage

Add [lein-difftest "1.2.2"] to your project’s :dev-dependencies.


$ lein deps
$ lein test

This plugin uses Robert Hooke to change the behavior of the Leiningen test task. If you want to go back to standard test output then you will need to remove this library from you classpath.

REPL Usage


user> (use 'difftest.core)
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.

Dependencies

Apart from Clojure, clojure.test and Leiningen, lein-difftest is built on top of other fine libraries:

License

Copyright © 2010 Brenton Ashworth

Distributed under the Eclipse Public License, the same as Clojure uses. See the file COPYING.

Something went wrong with that request. Please try again.