Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QuickCheck 2 batch processing

The Batch module of QuickCheck was removed with version 2 (1.2.0.1 still has it). Because of this, I'm always feeling like mapM_-ing multiple tests together is kind of hacky. Am I overlooking the successor feature in QuickCheck 2? Is there a canonical way of grouping independent tests together?

like image 357
David Avatar asked Nov 23 '12 17:11

David


1 Answers

There's the 'go big or go home' option of grouping together all tests in the current module via Test.QuickCheck.All. It requires Template Haskell, and all properties must begin with prop_. Ex:

{-# LANGUAGE TemplateHaskell #-}

import Test.QuickCheck.All

prop_one, prop_two :: a -> Bool
prop_one = const True
prop_two = const True

runTests :: IO Bool
runTests = $quickCheckAll

main :: IO ()
main = runTests >>= \passed -> if passed then putStrLn "All tests passed."
                                         else putStrLn "Some tests failed."
like image 92
jtobin Avatar answered Oct 18 '22 09:10

jtobin