Being a fan of quickCheck, I have a lot of
prop_something_something = ...
throughout my program.
For convenience, to easily run all of them, I define
runchecks = do
quickCheck prop_something_something
quickCheck prop_something_different
but is there a nice way to generate runchecks
?
TL;DR: I want to easily run all quickChecks in a file. I guess one way is to prefix the runnable tests with test_ or something similar, but that might be too hacky.
You can do this with the test-framework-th
package. Just do:
import Test.Framework.TH
import Test.Framework.Providers.QuickCheck2
runchecks = $(defaultMainGenerator)
This will use the test-framework
way of running tests, i.e. you'll get slightly more information than what you'd get by simply running the tests one after the other, which oftentimes is a good thing.
You obviously need TemplateHaskell
to be enabled for this to work; either add Default-extensions: TemplateHaskell
to your Cabal file, or add {-# LANGUAGE TemplateHaskell #-}
to the top of the file.