I am testing a random generator generating instances of my own type. For that I have a custom instance of Arbitrary
:
complexGenerator :: (RandomGen g) => g -> (MyType, g)
instance Arbitrary MyType where
arbitrary = liftM (fst . complexGenerator . mkStdGen) arbitrary
This works well with Test.QuickCheck
(actually, Test.Framework
) for testing that the generated values hold certain properties. However, there are quite a few properties I want to check, and the more I add, the more time it takes to verify them all.
Is there a way to use the same generated values for testing every property, instead of generating them anew each time? I obviously still want to see, on failures, which property did not hold, so making one giant property with and
is not optimal.
You could label each property using
printTestCase
before making a giant property withconjoin
.e.g. you were thinking this would be a bad idea:
this would be as efficient yet give you better output:
(Having said that, I've never used this method myself and am only assuming it will work;
conjoin
is probably marked as experimental in the documentation for a reason.)