Add clojure.test api to run single test with fixtures and report


When developing code, it is sometimes effective to focus on a single failing test, rather than running all tests in a namespace. This can be the case when running the tests takes some amount of time, or when running the tests produces a large volume of failures. The best option for running a single test with fixtures currently is `test-vars` ala:

However, this has the following issues:

  • No test reporting feedback such as you get with run-tests (on success, there is no output)

  • Need to specify var (not symbols) wrapped in a vector

Proposed: A new macro `run-test` that specifies a single symbol and does the same test reporting you get with `run-tests`. Usage:

Patch: CLJ-1908-3.patch

Screened: Alex Miller




Howard Lewis Ship
April 8, 2016, 8:51 PM

Updated patch, squashed and reflecting all of Alex's comments.

Howard Lewis Ship
April 4, 2016, 4:52 PM

Thanks for the input; I'll have an updated patch shortly.

Alex Miller
April 4, 2016, 3:23 PM

Some changes needed on this patch before I will prescreen it:

  • Patch should be squashed to a single commit

  • Commit message in patch should start with "CLJ-1908"

  • Change run-test* to run-test-var

  • The docstring for run-test-var should be: "Run the test in Var v with fixtures and report." Kill the "called from" sentence".

  • The first sentence of the docstring for run-test should be: "Runs a single test in the current namespace." Remove "This is meant to be invoked interactively, from a REPL.". Last sentence is ok.

  • In run-test, replace (ns-resolve ns test-symbol) with the simpler (resolve test-symbol).

Howard Lewis Ship
April 3, 2016, 6:27 PM

I think there is some advantage to being able to run the tests using is symbol, not its var. Further, the change I've suggested also returns the same kind of data that `run-tests` does.

Alex Miller
April 2, 2016, 12:43 AM

As far as I can tell, this is basically the same intent as CLJ-866 which was completed in Clojure 1.6. You can do this now with test-vars:

Your pinned fields
Click on the next to a field label to start pinning.




Howard Lewis Ship








Affects versions

Fix versions