hello, guys! how can I run my tests from repl? I'm using expectations
and cognitect.test-runner
, all defined in deps.edn
. From command line is everything ok, but I haven't yet figured out how to invoke the test-runner from repl... can u help-me?
@gleisonsilva If you use the latest version of Expectations, and use defexpect
from expectations.clojure.test
(with expect
etc from that namespace) instead of the top-level unnamed expect
(from expectations
), then it will all just work fine with Cognitect's test runner.
Or is that not the question you are asking?
it is not
the tests are running just fine
i mean.. it is running just fine from command line
but now I'm trying to run the tests from repl
but I haven't figured out yet how to do that
(clojure.test/run-all-tests)
should do it
That will run any tests you have loaded into the REPL.
Do I need to load that namespace before?
You need to load the namespaces of any tests you want run.
when I do (clojure.test/run-all-tests)
it is running tests from several namespaces... from clojure to libs that I've added as dependencies to my project...
is it right?
Sounds right.
ah ok
You can use run-tests
to specify a list of namespaces to check for tests if you don't want everything run.
i just saw that
thank you very much
And thank you for using Expectations 🙂
🙂 I thank you!
do you know some way to, using just deps.edn
(I mean.. no lein, no boot), to "watch" the file changes and automatically run the tests?
Probably the best option there is a separate file system watcher, for your O/S, that runs a command when files change (so it can run the clojure
command to run your tests).
I don't particularly like that as a workflow, preferring to run tests in my editor/REPL as I'm working on code since I can do that with hot keys, and work on specific tests -- and run tests without actually saving files.
I use Atom/ProtoREPL but CIDER supports that workflow too. Eval code, eval tests, working inside a file, sending code/commands to the REPL via hot keys (not typing anything into the REPL).
Saving files from time to time and either reloading them or manually kicking off a full test suite run externally (which takes minutes to run, including DB setup/teardown).
The problem with auto-runners -- in my experience with both Lein and Boot versions -- is that they can crash sometimes or get into a bad state if you save a file as you're editing and the file has syntax or other errors that cause it to fail compilation.
Also, I really don't want my full test suite kicking off every time I save code in case it changes the state of my system (e.g., DB) while I'm still working on stuff in my editor.