Reputation: 1186
Short version: It is possible to use the quickCheckAll
function in tasty-quickcheck?
Long version:
The quickCheckAll
function tests all properties beginning with prop_
in the current module as shows the following example:
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Test.QuickCheck ( quickCheckAll )
prop_1 :: Int -> Bool
prop_1 x = x + x == 2 * x
prop_2 :: Int -> Int -> Bool
prop_2 x y = x + y == y + x
-- Template Haskell hack to make the following $quickCheckAll work
-- under GHC >= 7.8.
return []
-- All properties as collected by 'quickCheckAll'.
runTests :: IO Bool
runTests = $quickCheckAll
main :: IO ()
main = runTests >> return ()
On the other hand, I can use QuickCheck in the Tasty test framework via the tasty-quickcheck package as shows the following example:
module Main where
import Test.Tasty ( defaultMain, testGroup, TestTree )
import qualified Test.Tasty.QuickCheck as QC
prop_1 :: Int -> Bool
prop_1 x = x + x == 2 * x
prop_2 :: Int -> Int -> Bool
prop_2 x y = x + y == y + x
tests :: TestTree
tests = testGroup "Tested by QuickCheck"
[ QC.testProperty "prop_1" prop_1
, QC.testProperty "prop_2" prop_2
]
main :: IO ()
main = defaultMain tests
It is possible to use the quickCheckAll
function on the above example for avoiding explicitly listing all the properties when using QuickCheck and Tasty?
Versions: The above examples were tested using GHC 8.2.2, QuickCheck 2.10.1 and tasty-quickcheck 0.9.1.
Upvotes: 1
Views: 339
Reputation: 33519
That doesn't seem possible with quickCheckAll
but the underlying logic could be reused by testing frameworks. Here's a new PR to get all properties in a list.
Upvotes: 2