Fork me on GitHub
#test-check
<
2022-09-23
>
markgdawson11:09:12

Does anyone know a simple way to have test.check change one parameter more slowly than another? So for example, parameter B changes every test whilst parameter A changes only every 10 tests.

colinkahn16:09:48

I don't know of any way to finely control generation per-test, but you could look at frequency

markgdawson16:09:42

Yeah, frequency isn't really what I'm after here. What I'd really like yo do is to spin up a system with generated config and then fire a request against the system. But the system is expensive to spin up, and I'm happy with a small number of instances of it. So I want to bootstrap a single system, fire multiple samplings of the other params against it then move on to another generated system.

colinkahn17:09:45

In that case I would write a test where your generator generators a collection that you can apply in loop over a single bootstrapped instance. I would make sure that you wrote it so it short circuits on the first failure. Shrinking might take a bit longer, but test check does a good job shrinking collections so you'll most likely end up just a vector of a single item.

colinkahn17:09:08

There's also a trick to writing a collection generator that targets a certain size but shrinks to zero, I'll see if I can find it

markgdawson17:09:56

Ah, i see. I was worried this approach wouldn't point me at the exact failure scenario. But you're saying I could achieve that by having the collection of failing tests shrink to the failing one. Smart idea, I'll give it a go!!

colinkahn17:09:19

Yep. That generator function above will let you tune how many to start the collection with (it won't always be exact, so you'll have to play around to see what the resulting item counts are), while still shrinking towards zero.