Skip to main content

QuickCheck integration

You can use sandwich-quickcheck (provided as a separate package) to easily integrate integrate QuickCheck tests into the test tree.

Haddocks can be found here.


To use sandwich-quickcheck, just add the package to your project. Then, introduce a QuickCheck argument context using introduceQuickCheck. Now you can start writing props as test nodes using the prop function. For example:
quickCheckDemo :: TopSpec
quickCheckDemo = describe "QuickCheck tests" $ introduceQuickCheck $ do
prop "List reversal" $ \(xs :: [Int]) -> reverse (reverse xs) == xs
prop "Failing list reversal" $ \(xs :: [Int]) -> (reverse xs) == xs

Modifying the args#

If you use introduceQuickCheck', you can pass your own value for the QuickCheck Args. The default version uses stdArgs.

If you want to modify the already-introduced arguments in a test tree, we provide the modifyArgs function, as well as helpers like modifyMaxSize, modifyMaxDiscardRatio, etc. These are modelled directly after HSpec's Test.Hspec.QuickCheck.

Controlling QuickCheck parameters with command line args#

There are not (yet) any built-in command line arguments for controlling QuickCheck parameters such as maxSize. However, you can add custom command line options to control any parameters you like.