Hi all. I've just written my first clojure.test test 🙂 but I've noticed than using (run-all-tests)
in the repl lists out "Testing xxx" for every namespace, so I have to wade through 500 lines of irrelevant output to find out the test that failed. Is there any simple way to get round that? It's just a small one-man project so I don't want to set up any complicated CI
(clojure.core/->> (clojure.core/all-ns)
(clojure.core/filter (clojure.core/fn [n]
(clojure.core/->> n
clojure.core/ns-publics
clojure.core/vals
(clojure.core/some (clojure.core/fn [var-ref]
{:pre [(clojure.core/var? var-ref)]}
(clojure.core/-> var-ref clojure.core/meta :test))))))
(clojure.core/sort-by clojure.core/pr-str)
(clojure.core/apply clojure.test/run-tests))
I have this as a IDE snippet (e.g yasnippet
) that I can expand in the replthanks I'll try that out 🙂
I've used weavejester/eftest
on a few projects, it's a fairly minimal test runner, you might want to take a look at that. https://github.com/weavejester/eftest
I have hot keys bound to a) essentially (clojure.test/run-tests *ns*)
to run all the tests in the current namespace and b) code that constructs a test ns name from the current ns (e.g., by sticking -test
on it), requiring it, and then running tests in that ns.
https://github.com/seancorfield/vscode-clover-setup/blob/develop/config.cljs#L112-L117 -- it tries -test
first and then -expectations
because we have a lot of tests at work that use https://github.com/clojure-expectations/clojure-test (because I prefer that syntax, but wanted it to be compatible with all the clojure.test
tooling).