ClojureCheck — a Unit Test Library
Description
ClojureCheck is a an implementation of the Test Anything Protocol for Clojure. Currently ClojureCheck implements version v1.00 of TAP. Furthermore ClojureCheck contains a port of Haskell's QuickCheck. This is not completely finished at the moment.
TAP basically consists of a test plan and a number of test cases. It prints the test results in simple textual format, which can be easily parsed by a test harness as well as the user should it be necessary.
There are several harnesses readily available, like the perl prove utility or the perlprove compiler plugin for Vim, which reads the test output and provides the results for easy handling in a quickfix window.
The actual test functions are inspired by Test::Simple and
Test::More of Perl.
Example
The following is a simple test script might look like the following:
(require '[de.kotka.tap :as tap])
(tap/plan 4)
(tap/ok? (nil? nil) "nil is nil")
(tap/is? (- 2 1) 1 "one is equal to one")
(tap/is? (+ 0 1) 0 "one is equal to zero")
(tap/todo
(tap/ok? (taken-over? 'world) "take over the world"))
Running the test script might result in the following output:
1..4
ok 1 - nil is nil
ok 2 - one is equal to one
not ok 3 - one is equal to zero
# Expected: (+ 0 1)
# To be: 0
# But was: 1
not ok 4 # TODO - take over the world
Download
Development Version: http://bitbucket.org/kotarak/clojurecheck