How do I get good (small) shrinks out of QuickCheck?
FWIW, have a look at https://github.com/leepike/SmartCheck, which claims to derive better shrinks than one can usually do manually.
FWIW, have a look at https://github.com/leepike/SmartCheck, which claims to derive better shrinks than one can usually do manually.
A year later, I now think I have an answer to this question: No! In particular, unit tests will always be necessary and useful for regression tests, in which a test is attached to a bug report and lives on in the codebase to prevent that bug from ever coming back. However, I suspect that … Read more
Yes, well. Actually no, but I’ve studied under the man who originally developed QuickCheck and he’s a really interesting guy. Back in 2004, we were forced to use QuickCheck to test our Haskell programs and it was combination of good and bad. Mostly bad because Haskell was a bit daunting itself but never the less … Read more
Writing an instance of Arbitrary for your data type is easy. You just have to implement the arbitrary function, which should return a Gen Cell. The simplest way to do this is to make use of existing Arbitrary instances and also note that Gen is a monad, so we can use do-notation: instance Arbitrary Cell … Read more
I’ve seen one major advancement in QuickCheck 2, I think as important as monadic code testing, if not more : class Arbitrary a where arbitrary :: Gen a shrink :: a -> [a] This, is really awesome. The shrink method is optional, but if you can provide a list of “possibly empty” reduction of your … Read more
When QuickCheck finds an input that violates a property, it will first try to find smaller inputs that also violate the property, in order to give the developer a better message about the nature of the failure. What it means to be „small“ of course depends on the datatype in question; to QuickCheck it is … Read more
The Test.QuickCheck.Monadic module lets you test monadic code, even things that run in IO. A monadic property test is of type PropertyM m a, where m is the monad the test runs in and a is ultimately ignored. In the case of PropertyM IO a, you convert the monadic test to a Property by using … Read more