I'm in a situation where test data is generated with Arbitrary and generate and is very useful, but not unique enough.
Part of this is due to shrinking I believe, which I've tried to disable where I can.
Using resize for values like UUID seems to help in some places... but things are still flaky.
Due to tests taking too long and not enough time to fix it another way, we had to introduce a shared database which creates test pollution and necessitates uniqueness of arbitrary values.
Even without test pollution though, some of the arbitrary data is used in data types that are inserted to a database containing Uniqueness constraints.
The xorshift random generator has no repetitions by design. You could try it. (the statement above holds for the first 2^64 or so numbers. - source
That led me to Gen and I saw that it uses TFGen which uses the RandomGen interface.
The xorshift random generator implementation here also supports RandomGen so it seems possible to use xorshift to solve the problem I currently have without writing 100s of custom Arbitrary instances.
However, it's very unclear how I'd use Quickcheck with a different random number generator.
Another quick "fix" being disabling shrinking everywhere, but that could make tests take much longer again.
I'm in a situation where test data is generated with
Arbitrary
andgenerate
and is very useful, but not unique enough.Part of this is due to shrinking I believe, which I've tried to disable where I can.
Using
resize
for values likeUUID
seems to help in some places... but things are still flaky.Due to tests taking too long and not enough time to fix it another way, we had to introduce a shared database which creates test pollution and necessitates uniqueness of arbitrary values.
Even without test pollution though, some of the arbitrary data is used in data types that are inserted to a database containing Uniqueness constraints.
Doing some research I came across this comment on Haskell QuickCheck Unique Random Number Generation:
That led me to Gen and I saw that it uses TFGen which uses the
RandomGen
interface.The xorshift random generator implementation here also supports
RandomGen
so it seems possible to use xorshift to solve the problem I currently have without writing 100s of custom Arbitrary instances.However, it's very unclear how I'd use Quickcheck with a different random number generator.
Another quick "fix" being disabling shrinking everywhere, but that could make tests take much longer again.