Libraries like RCF support a programming style where tests are written inline with the source code and always run when the test form is evaluated (for example if the file is reloaded) for fast feedback and better locality of tests and examples - small example tests sit next to the code, and unlike comment
blocks, are at lower risk of going out of sync with the code base.
This way, forms wrapped with with-tests
, deftest
and set-test
will run their tests when they're evaluated.
This isn't suitable for long running or heavy tests, which is why having a dynamic var which could be set per namespace seems like a decent fit.
RCF achieves it by always adding a call to test-var at the end of the test form:
e.g.
(when *run-tests* `(test-var (var ~name)))
Then tests written inline with code will be able to run automatically when code is loaded and provide immediate feedback
Alternative: use tools.namespace
Thouhghts?