Search code examples
testingclojureread-eval-print-loop

Run one Clojure test (not all tests in a namespace), with fixtures, from the REPL


How do I run one test (not a whole namespace) from the Clojure REPL?

I've tried calling the function directly, e.g. (the-ns/the-test) but I need fixtures to run first. So I want to find a way to start the tests from clojure.test.

This is close but not a match for what I want to do: https://stackoverflow.com/a/24337705/109618

I don't see any mention of how to do it from the clojure.test API.


Solution

  • There was a new function added in Clojure 1.6 to support this. clojure.test/test-vars will run one or more test vars with fixtures.

    I think something like this should work:

    (clojure.test/test-vars [#'the-ns/the-test])