cognitect-labs / test-runner

A test runner for clojure.test
Eclipse Public License 2.0
287 stars 31 forks source link

Support :only option for running single ns or var #40

Closed borkdude closed 2 years ago

borkdude commented 2 years ago

For people used to leiningen, the :only option can be convenient to run either a whole namespace or a single test from a namespace.

Especially when paired with error reporting, where :only foo.bar/baz-test is printed when foo.bar/baz-test is failing, so you can copy paste that in the command line.

I did not include the printing in this PR, but can do another PR if that seems a good idea.

puredanger commented 2 years ago

I find myself a bit on the fence about this change as it is already covered by use of the existing :nses '[a-ns]' or :vars '[a-ns/a-var]' (although the first of those has the same issue with :patterns), and since these are both collection options they are definitely more onerous on the user to handle the quoting. I would still be willing to merge this, but the above issues need to be addressed.

borkdude commented 2 years ago

@puredanger Addressed in new commit:

In the case of :only a-ns/a-var, the namespace doesn't get required and the var can't be found.

I could not reproduce that, I can see the namespace appear in :nses that are to be required in the test function and this is why I added a test for the only behaviour which does not seem to exhibit the bug.

borkdude commented 2 years ago

As this option is considered "on the fence", I'm closing this. neil test :only ... is now supported which forwards the argument to the cognitect test runner either as -v or as -n.