testing

Testing tools, testing philosophy & methodology...
gleisonsilva 2018-11-21T21:50:43.007800Z

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?

seancorfield 2018-11-21T21:54:03.009100Z

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

seancorfield 2018-11-21T21:54:24.009400Z

Or is that not the question you are asking?

gleisonsilva 2018-11-21T21:54:33.009600Z

it is not

gleisonsilva 2018-11-21T21:54:40.010Z

the tests are running just fine

gleisonsilva 2018-11-21T21:54:55.010400Z

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

gleisonsilva 2018-11-21T21:55:05.010700Z

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

gleisonsilva 2018-11-21T21:55:32.011300Z

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

seancorfield 2018-11-21T21:55:48.011600Z

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

seancorfield 2018-11-21T21:55:58.012100Z

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

gleisonsilva 2018-11-21T21:56:14.012600Z

Do I need to load that namespace before?

seancorfield 2018-11-21T21:56:27.013Z

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

gleisonsilva 2018-11-21T21:58:31.014800Z

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

gleisonsilva 2018-11-21T21:58:38.015100Z

is it right?

seancorfield 2018-11-21T21:59:25.015400Z

Sounds right.

gleisonsilva 2018-11-21T22:00:03.016100Z

ah ok

seancorfield 2018-11-21T22:00:03.016200Z

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

gleisonsilva 2018-11-21T22:00:08.016500Z

i just saw that

gleisonsilva 2018-11-21T22:00:13.016800Z

thank you very much

seancorfield 2018-11-21T22:00:26.017400Z

And thank you for using Expectations 🙂

gleisonsilva 2018-11-21T22:00:39.017700Z

🙂 I thank you!

gleisonsilva 2018-11-21T22:02:00.018700Z

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?

seancorfield 2018-11-21T22:07:14.019600Z

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

seancorfield 2018-11-21T22:09:57.021100Z

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.

seancorfield 2018-11-21T22:11:03.022300Z

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

seancorfield 2018-11-21T22:12:08.023300Z

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

seancorfield 2018-11-21T22:13:00.024400Z

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.

seancorfield 2018-11-21T22:13:52.025300Z

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.