testing

Testing tools, testing philosophy & methodology...
2015-09-28T10:48:39.000027Z

Hi. I'm just in my first days of testing with test.check and prismatic schema. I ran into performance issues right away as a suite of about 20 tests took already 80 seconds. Nope I'm not talking GUI. Those were generator-unit-tests. If anyone has the same problem, this is what helped me a lot: http://blog.muhuk.com/2015/09/17/performance_tuning_clojure_generative_tests.html#.VgjjWSCqpBc I decided to cache the really expensive datastructures. Now those same checks run in ~2.5 seconds

nberger 2015-09-28T13:33:48.000028Z

Cool! Good to know about your experience. I guess caching has to be taken with care, to not reduce the "randomness" so much, but seems like a good strategy when you have a combination of generators, some of which are "expensive". You lose the shrinking on them though...

2015-09-28T20:12:44.000029Z

@nberger: I think I don't lose the shrinking. But I can't repeat the checks. That's at least what the blog said and I think I got pretty ok results so far.

2015-09-28T20:14:03.000030Z

Yes, reducing the randomness too much will be contraproductive but I think I got enough from that still. Especially when I compile anew

nberger 2015-09-28T20:15:00.000031Z

@meikemertsch: I should have been more precise... you don't lose it, but you get shrinking of a different thing... From the example, the idea is to use something like:

(def gen-key
  (let [ks (gen/sample gen/keyword 30)]
    (gen/elements ks)))
instead of gen/keyword

2015-09-28T20:15:31.000032Z

Yes, gotcha so far..

2015-09-28T20:15:43.000033Z

Ah, I think I see where you're going

nberger 2015-09-28T20:15:47.000034Z

well, the shrinking of that (gen/elements ...) runs by discarding elements from the left side, so giving more probability to the elements to the right...

nberger 2015-09-28T20:16:18.000035Z

that's not exactly the same as shrinking the keyword :foo, which would give you something like :fo or :f I think...

2015-09-28T20:16:19.000036Z

It can't shrink as much as with genuinely generated data

2015-09-28T20:16:36.000037Z

Yes

nberger 2015-09-28T20:16:36.000038Z

what do you mean by "genuinely generated"? :simple_smile:

2015-09-28T20:16:56.000039Z

Directly generated I guess 😅

nberger 2015-09-28T20:17:04.000040Z

You mean "by hand"?

2015-09-28T20:17:06.000041Z

Without caching

nberger 2015-09-28T20:17:06.000042Z

:simple_smile:

nberger 2015-09-28T20:17:09.000043Z

Oh, ok

nberger 2015-09-28T20:18:06.000044Z

Well, imaging you would get :some-loong-keyword-with-+_weird-chars from gen/keyword, as opposed of it being one of the elements from that (gen/elements ...)

nberger 2015-09-28T20:19:39.000045Z

when shrinking, I guess that gen/keyword will shrink towards shorter versions of that :some-loong... keyword... (gen/elements ...) will shrink toward elements to the right of that keyword, so it will give you a keyword that most probably will not be a shorter version of that keyword :simple_smile:

nberger 2015-09-28T20:19:46.000046Z

most of the times you won't care about this...

nberger 2015-09-28T20:20:26.000047Z

But I just wanted to point it out :simple_smile:

2015-09-28T20:20:47.000048Z

But there might be days ;) it's better to be aware! Thanks!

2015-09-28T20:21:08.000049Z

I learned something about the shrinking in that process 😅

2015-09-28T20:21:36.000050Z

But now I'll hit the sack. It's late here 😊

nberger 2015-09-28T20:21:58.000051Z

Cool :

nberger 2015-09-28T20:22:00.000052Z

:simple_smile: