Drop-in replacements for clojure.test/{deftest,testing} that (when used
together) enhances uncaught exception error messages with the (most likely)
testing context it was thrown from.
Example:
(deftest my-test (testing "foo" (doseq [v [1 2 3]] (testing v (assert (= 1 v))))))
With clojure.test/{deftest,testing} 1.10.3 (notice foo 2 is not mentioned):
user=> (test-var #'my-test) ;ERROR in (my-test) ;Uncaught exception, not in assertion. ;expected: nil ;actual: java.lang.AssertionError: Assert failed: false ;...
With {deftest,testing} in this namespace (notice foo 2 is mentioned):
user=> (test-var #'my-test) ;ERROR in (my-test) ;Uncaught exception, possibly thrown in testing context: foo 2 ;expected: nil ;actual: java.lang.AssertionError: Assert failed: false ;...
Drop-in replacements for `clojure.test/{deftest,testing}` that (when used
together) enhances uncaught exception error messages with the (most likely)
testing context it was thrown from.
Example:
(deftest my-test
(testing "foo"
(doseq [v [1 2 3]]
(testing v
(assert (= 1 v))))))
With clojure.test/{deftest,testing} 1.10.3 (notice `foo 2` is not mentioned):
user=> (test-var #'my-test)
;ERROR in (my-test)
;Uncaught exception, not in assertion.
;expected: nil
;actual: java.lang.AssertionError: Assert failed: false
;...
With {deftest,testing} in this namespace (notice `foo 2` is mentioned):
user=> (test-var #'my-test)
;ERROR in (my-test)
;Uncaught exception, possibly thrown in testing context: foo 2
;expected: nil
;actual: java.lang.AssertionError: Assert failed: false
;...(-run-test-body f)For libraries that mimic clojure.test's API. f should be a thunk that runs the test.
For libraries that mimic clojure.test's API. f should be a thunk that runs the test.
(deftest+report-uncaught-contexts name & body)Like clojure.test/deftest, except swallows uncaught exceptions
and reports them as test errors (with improved error messages via
exceptional-testing-contexts). This is normally done by test-var,
with an unhelpful error message.
Use in conjunction with testing in this namespace.
Like clojure.test/deftest, except swallows uncaught exceptions and reports them as test errors (with improved error messages via *exceptional-testing-contexts*). This is normally done by `test-var`, with an unhelpful error message. Use in conjunction with `testing` in this namespace.
(record-uncaught-exception-contexts e)Call when an exception is thrown in a testing context to record the most likely testing-contexts to report in exceptional-testing-contexts.
Call when an exception is thrown in a testing context to record the most likely *testing-contexts* to report in *exceptional-testing-contexts*.
(report-uncaught-exception e)Report an uncaught exception using exceptional-testing-contexts to guess the most helpful message.
Report an uncaught exception using *exceptional-testing-contexts* to guess the most helpful message.
(testing+record-uncaught-contexts string & body)Like clojure.test/testing, except records testing contexts on uncaught exceptions.
Use in conjunction with deftest in this namespace.
Like clojure.test/testing, except records testing contexts on uncaught exceptions. Use in conjunction with `deftest` in this namespace.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |