testing

Testing tools, testing philosophy & methodology...
vuuvi 2017-09-21T14:11:07.000417Z

can someone help explain to me why clojure.test isn’t trying to compare the evaluation of a function I’ve written?

expected: (= (hello_world) "Hello World!")
  actual: (not (= "Hello, World!" "Hello World!"))

donaldball 2017-09-21T14:12:25.000272Z

I think you may be misunderstanding the output

2017-09-21T14:12:31.000408Z

the expected shows the forms, the actual shows the values

donaldball 2017-09-21T14:12:35.000497Z

^--

2017-09-21T14:13:23.000456Z

since the actual values in the form make it much easier to see what made the test fail, usually

vuuvi 2017-09-21T14:22:28.000024Z

the actual output is what I want, not what I want expected

2017-09-21T14:23:49.000350Z

the expected part is also useful, because it shows me exactly what form was evaluated to get a given value

2017-09-21T14:24:03.000130Z

(though of course you can easily see that by reading the test)

vuuvi 2017-09-21T14:24:11.000316Z

yeah I know! But the thing that’s confusing me is the expected output is more literal than I want

2017-09-21T14:24:25.000571Z

I fix this with a let block

vuuvi 2017-09-21T14:24:28.000469Z

I just want to test that the string the hello_world function returns is “Hello World!”

2017-09-21T14:24:39.000324Z

that is what you are testing...

vuuvi 2017-09-21T14:28:25.000171Z

okay that’s what I thought - then why is it returning false?

2017-09-21T14:28:36.000689Z

because one has a comma in it

2017-09-21T14:28:57.000197Z

there's a plugin, "lein difftest" that highlights data differences in assertions btw

vuuvi 2017-09-21T14:29:19.000043Z

oh wow that’s a stupid mistake

2017-09-21T14:29:23.000584Z

it works with the tests you have already, it just uses different output formats to make it more clear

vuuvi 2017-09-21T14:29:26.000274Z

thanks for the info / second set of eye balls

vuuvi 2017-09-21T14:29:40.000026Z

that’s great I didn’t know about that!