testing

Testing tools, testing philosophy & methodology...
vinai 2017-04-07T06:49:43.376026Z

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.

fossifoo 2017-04-07T07:06:22.566762Z

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

👆 1
fossifoo 2017-04-07T07:06:26.567551Z

might help

vinai 2017-04-07T07:06:45.571122Z

Thanks @fossifoo, googling

vinai 2017-04-07T07:09:40.605139Z

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

vinai 2017-04-07T07:12:14.635682Z

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

fossifoo 2017-04-07T07:13:05.646371Z

yeah, i never used that from the repl, sorry

vinai 2017-04-07T07:15:16.672319Z

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

fossifoo 2017-04-07T07:17:46.703828Z

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

fossifoo 2017-04-07T07:18:54.717622Z

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

fossifoo 2017-04-07T07:19:35.725877Z

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

vinai 2017-04-07T07:22:14.758860Z

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.

vinai 2017-04-07T07:28:50.844387Z

No luck

fossifoo 2017-04-07T11:26:55.468042Z

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

fossifoo 2017-04-07T11:27:53.480439Z

summarize-results says {:total 0} 😞

fossifoo 2017-04-07T11:29:33.503047Z

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

fossifoo 2017-04-07T12:56:11.831489Z

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

fossifoo 2017-04-07T13:01:58.949710Z

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

fossifoo 2017-04-07T14:57:53.858151Z

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

fossifoo 2017-04-07T14:58:17.869432Z

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