Fork me on GitHub

I wrote a little essay about growth & shrinking of test.check generators:


Is it considered bad practice to employ custom generators to produce values that lead to decent perf of the functions being checked? Motivation: You have a function which, for certain valid inputs, would slow down checking considerably. Would it be considered an abuse of s/with-gen for this purpose, or is there a better way, or is this still an open question?


A concrete hypothetical example: Testing the 2-arg arity of repeat. You want the spec to allow any number for n, but you want to limit the size of the generated values of n, just for testing purposes.


@mfikes Seems like the essay @gfredericks just posted here is relevant to your question: -- it only hints at sizing being relevant for performance (memory usage) but in general I think it makes sense to apply custom generators for this purpose. I don't have authority on blessing it as a good practice, though 🙂


Seems fine to me


You can also supply the generators at test time rather than in the registered spec if you want smaller scope


With gen overrides


👍 to all that