Hi, running my tests always returns with exit code 0 even when some tests fail. This makes running the test suite in CI useless. Am I doing something wrong or how do others run their tests in CI?
You've basically created your own minimal test runner @josephson.victor :)
lein test
returns non zero error code when test fails. What do you use to run tests?
Ah I don’t use lein, my poject uses deps
right now my work-around looks something like this:
(defn -main []
(let [{:keys [fail error]} (test-all)]
(System/exit (if (zero? (+ fail error)) 0 1))))
And test-all
is just a function that finds all my namespaces and runs (apply run-tests namespaces)
And I execute the program with clj -M:test
. So, it kind of works thanks to the System/exit call but that feels like a hack
I don't use deps, but last time I've looked into it people used test runners like https://github.com/cognitect-labs/test-runner or https://github.com/lambdaisland/kaocha. With those you could remove logic that discovers tests and produces exit code
thanks I’ll check those out!:)
@josephson.victor We use Cognitect’s test-runner
in our BitBucket Pipelines CI at work and like it a lot (especially now it has the -X
/ exec args invocation so we can merge test arguments across multiple aliases.
(you can’t merge :main-opts
across aliases — but you can merge :exec-args
!)