cider icon indicating copy to clipboard operation
cider copied to clipboard

Support `cider-test-run-test` from the `src` NS

Open MicahElliott opened this issue 4 years ago • 4 comments

Presently, this can only be called from the test NS.

It would be nice if you could call cider-test-run-test from the src NS, instead of having to run the whole cider-test-run-ns-tests.

This should be possible if your deftest function is named consistently with the source function. So with point on source function foo, invoking cider-test-run-test would look for a corresponding test named foo or foo-test (considering that the style guide now now encourages it).

The only alternative I see now is using -with-filters but that's not too convenient.

MicahElliott avatar Dec 29 '20 20:12 MicahElliott

That's a good idea and it should be fairly simple to implement.

bbatsov avatar Dec 30 '20 10:12 bbatsov

Hi, I'd really like to work on this if there is still a desire for this functionality. From my understanding, the desired functionality is for cider-test-run-test to function in a similar way to cider-test-run-ns-tests by searching for the foo-test namespace, but only for the single test at point instead of all tests in the ns?

hodgiwabi avatar Apr 06 '21 22:04 hodgiwabi

I think the use case is the following:

  • I'm the foo ns
  • There I'm in the definition of bar (e.g. a function)
  • I run cider-test-run-test and it finds the matching test bar-test in a namespace called foo-test and runs it.

bbatsov avatar Apr 07 '21 06:04 bbatsov

Seems to me the third bullet should read:

  • I run cider-test-run-test and it finds the matching test function bar-test in a namespace called foo-test and runs it.

MicahElliott avatar Apr 07 '21 20:04 MicahElliott

CIDER master / 20230926.1139 features a revamped cider-test-run-test (run test at point).

Now, it will run the first valid test found at point for:

  • the current *cider-test-report* failure
  • deftests, and deftest-like forms (cider-test-defining-forms is no longer necessary and now deprecated) in the current namespace
  • :test metadata that may be present in vanilla defns
  • deftests for the current src/ defn, as found (and configurable) by cider-test-infer-test-ns
    • We search for a var named foo-test in that inferred ns, falling back to foo

Docs: https://docs.cider.mx/cider/testing/running_tests.html

vemv avatar Sep 26 '23 13:09 vemv