testing

Testing tools, testing philosophy & methodology...
jaime 2020-08-09T20:02:54.097800Z

Hello, which tool will you recommend to see the diff in test assertions when they fail?

seancorfield 2020-08-09T20:35:55.098800Z

Paul Stadig's Humane Test Output is fairly good for that (although there are some caveats around using it with Leiningen, since both tools try to modify the test reporting machinery -- so check the docs).

seancorfield 2020-08-09T20:36:34.099Z

https://github.com/pjstadig/humane-test-output

jaime 2020-08-09T20:46:29.100700Z

Is it possible to integrate it with clojure cli? I'm not familiar with lein :injections, it seems like you have to call the (pjstadig.humane-test-output/activate!) in every test namespace?

seancorfield 2020-08-09T20:47:02.101300Z

No, you only need to call that once, so you can use a :main-opts in your alias to do that.

seancorfield 2020-08-09T20:48:29.103200Z

(if you use expectations/clojure-test it does that automatically for you, but I assume you're working with clojure.test and Cognitect's test-runner?)

vemv 2020-08-09T20:49:36.104Z

My approach is invoking https://github.com/lambdaisland/deep-diff2 or its predecessor, by hand, whenever I need it I'd understand the natural instict to automate this altogether but I don't think it has been accomplished in a clean and universal manner yet. IME, one truly wants a diff 1-3% of the time (which is still a lot!) so it's not particularly worth it to automate much.

vemv 2020-08-09T20:49:57.104300Z

by hand actually means triggering an IDE snippet, to save me part of the invocation https://raw.githubusercontent.com/zenmacs/.emacs.d/master/snippets/clojure-mode/diff

seancorfield 2020-08-09T20:50:58.105900Z

@vemv I agree to some extent. I do find that HTO makes some failures harder to read, but overall it makes many failures a lot better.

1👍
jaime 2020-08-09T20:50:59.106Z

@seancorfield I'm using clojure.test and running the test using intellij plugin cursive, it has a command to run the current deftest.

jaime 2020-08-09T20:51:35.107Z

Previously, cursive has a pop=up to show the diff, not sure why its not there anymore

onetom 2020-08-17T01:51:36.115100Z

that diff is only available if the test failure follows a certain format. eg. it expects (is (= ... in the failure output. https://github.com/clojure-expectations/clojure-test prints (is (?= ... and that won't be recognized, so you won't see the Show diff... link

jaime 2020-08-18T21:44:54.115300Z

:thinking_face: For this test failure, I think it should show the "show diff link" right?

seancorfield 2020-08-09T20:52:07.107600Z

@jaime.sangcap I was just about to say: I thought Cursive already did that for you? Maybe ask in #cursive ?

seancorfield 2020-08-09T20:52:50.108300Z

(I use Atom/Chlorine and I can run a single deftest too but rely on the REPL output window)

jaime 2020-08-09T20:54:18.109600Z

Yes I'm thinking to ask it on that channel. I'm trying to improve the cursive experience a bit, at least to show the diff in the repl everytime I run the test using cursive

jaime 2020-08-09T20:55:48.109700Z

Interesting, seems like emacs specific?

vemv 2020-08-09T21:04:30.109900Z

I think Cursive also has a snippet system, or at least it's a common feature across ides

jaime 2020-08-09T21:07:10.110100Z

Oh cool. Will look into it. Thanks!