Using clojure.test, when running lein test
, the default settings only print out the number of assertions, like "Ran 12 tests containing 19 assertions," the details for failed tests, and the namespaces tested. I would like an output of the successful tests as well, so I can see what tests were actually run. Frameworks like Mocha in JS have this behavior by default.
For instance, if the following test passed:
(deftest aTest
(testing "Simple test"
(is (= 1 1))))
I would like an output like (formatting is arbitrary):
Testing <namespace>
Passed: aTest -> Simple test
Ideally, the passed test would also be color coded.
I looked at a few libraries, including lein-test-refresh and humane-test-output, but didn't see what I needed. The other option looks like to rewrite the report function in clojure.test, but I'd like to avoid that if possible.
I have searched multiple times for an answer to this question, so here is a complete solution building on @ivan-grishaev's hint using Test Report:
Test Report hooks into
clojure.test
to provide custom reporters that are then being run with every event occuring through a test run. Those events are passed as maps called "messages". The minimal example just appliesclojure.pprint/pprint
to the messages, but this only gets you so far. Here is a bit more code to give you a feel how to write custom reporters. Theindenting-reporter
indents test namespaces,deftest
s andtesting
vars, and lists them all independent of test outcome.Create a file like this in your project:
and then use it in the
:test
profile of yourproject.clj
:You could now go on an add color to the outputs.