Fork me on GitHub
#testing
<
2017-04-07
>
vinai06:04:43

I'm doing (is (= expected-long-string (generate-long-string))) in a clojure.test test. The string contains many lines separated by newlines. If the test fails, clojure.test displays them as a single long line comparison failed in the report, the newlines are shown as \n. Is there a function that will show me some kind of diff of the two strings? It would be much more easy to spot the difference in the actual result compared to the generated string that way.

fossifoo07:04:22

@vinai there's something called "humane test output" or such

vinai07:04:45

Thanks @fossifoo, googling

vinai07:04:40

Loads without error but doesn't work with cider version > 0.10. I'm using 0.14.

vinai07:04:14

Oh noes, seems like it won't be fixed soon. The issue has been open for a almost exactly a year now (https://github.com/clojure-emacs/cider-nrepl/issues/336).

fossifoo07:04:05

yeah, i never used that from the repl, sorry

vinai07:04:16

no worries, thanks for your help! I would be surprised if there is no workaround somehow.

fossifoo07:04:46

well i guess you could just rewrite your test to check that the diff between the strings is nil

fossifoo07:04:54

but i guess most diff functions (including data/diff) dont work so well on character based changes

fossifoo07:04:35

so if you are checking EDN or JSON or such, i would maybe not serialise it or deserialize prior to chekcing

vinai07:04:14

This is going to be a scaffold test based on stdout output of a legacy application, so I'm pretty much stuck with string comparison. However... if I split that by lines into a vector, maybe then the output is nicer.

fossifoo11:04:55

i'm trying to get spec.test/check to work, but it only produces () when i add (stest/check ['sut/make-log]) to my test ns

fossifoo11:04:53

summarize-results says {:total 0} 😞

fossifoo11:04:33

hmmm. i think i'll try to get a simpler example to run

fossifoo12:04:11

yay. it "works". now i get "clojure.spec/failure :no-gen"

fossifoo13:04:58

ah, i messed up the args spec. this still feels very much like a "no training weels" experience

fossifoo14:04:53

are there any tools around to handle midje & clojure.test & spec.check?

fossifoo14:04:17

it seems to me that test.check is very "bare bones"