Hello, which tool will you recommend to see the diff in test assertions when they fail?
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).
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?
No, you only need to call that once, so you can use a :main-opts
in your alias to do that.
(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
?)
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.
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
@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.
@seancorfield I'm using clojure.test and running the test using intellij plugin cursive, it has a command to run the current deftest.
Previously, cursive has a pop=up to show the diff, not sure why its not there anymore
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
:thinking_face: For this test failure, I think it should show the "show diff link" right?
@jaime.sangcap I was just about to say: I thought Cursive already did that for you? Maybe ask in #cursive ?
(I use Atom/Chlorine and I can run a single deftest
too but rely on the REPL output window)
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
Interesting, seems like emacs specific?
I think Cursive also has a snippet system, or at least it's a common feature across ides
Oh cool. Will look into it. Thanks!