Work in progress.
This is intended to eventually be a drop-in replacement for clojure.test, with some improvements.
Work in progress. This is intended to eventually be a drop-in replacement for clojure.test, with some improvements. - deftest will kick-off a test run unless one is already in progress, for easy in-buffer eval
(deftest name & body)
Defines a test function with no arguments. Test functions may call other tests, so tests may be composed. If you compose tests, you should also define a function named test-ns-hook; run-tests will call test-ns-hook instead of testing all vars.
Note: Actually, the test body goes in the :test metadata on the var, and the real function (the value of the var) calls test-var on itself.
When load-tests is false, deftest is ignored.
Defines a test function with no arguments. Test functions may call other tests, so tests may be composed. If you compose tests, you should also define a function named test-ns-hook; run-tests will call test-ns-hook instead of testing all vars. Note: Actually, the test body goes in the :test metadata on the var, and the real function (the value of the var) calls test-var on itself. When *load-tests* is false, deftest is ignored.
(is form)
(is form msg)
Generic assertion macro. 'form' is any predicate test. 'msg' is an optional message to attach to the assertion.
Example: (is (= 4 (+ 2 2)) "Two plus two should be 4")
Special forms:
(is (thrown? c body)) checks that an instance of c is thrown from body, fails if not; then returns the thing thrown.
(is (thrown-with-msg? c re body)) checks that an instance of c is thrown AND that the message on the exception matches (with re-find) the regular expression re.
Generic assertion macro. 'form' is any predicate test. 'msg' is an optional message to attach to the assertion. Example: (is (= 4 (+ 2 2)) "Two plus two should be 4") Special forms: (is (thrown? c body)) checks that an instance of c is thrown from body, fails if not; then returns the thing thrown. (is (thrown-with-msg? c re body)) checks that an instance of c is thrown AND that the message on the exception matches (with re-find) the regular expression re.
(testing string & body)
Adds a new string to the list of testing contexts. May be nested, but must occur inside a test function (deftest).
Adds a new string to the list of testing contexts. May be nested, but must occur inside a test function (deftest).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close