Fork me on GitHub
#testing
<
2018-11-21
>
gleisonsilva21:11:43

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?

seancorfield21:11:03

@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.

seancorfield21:11:24

Or is that not the question you are asking?

gleisonsilva21:11:40

the tests are running just fine

gleisonsilva21:11:55

i mean.. it is running just fine from command line

gleisonsilva21:11:05

but now I'm trying to run the tests from repl

gleisonsilva21:11:32

but I haven't figured out yet how to do that

seancorfield21:11:48

(clojure.test/run-all-tests) should do it

seancorfield21:11:58

That will run any tests you have loaded into the REPL.

gleisonsilva21:11:14

Do I need to load that namespace before?

seancorfield21:11:27

You need to load the namespaces of any tests you want run.

gleisonsilva21:11:31

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...

seancorfield22:11:03

You can use run-tests to specify a list of namespaces to check for tests if you don't want everything run.

gleisonsilva22:11:08

i just saw that

gleisonsilva22:11:13

thank you very much

seancorfield22:11:26

And thank you for using Expectations 🙂

gleisonsilva22:11:39

🙂 I thank you!

gleisonsilva22:11:00

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?

seancorfield22:11:14

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).

seancorfield22:11:57

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.

seancorfield22:11:03

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).

seancorfield22:11:08

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).

seancorfield22:11:00

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.

seancorfield22:11:52

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.