quickcheck
quickcheck copied to clipboard
Property setup/teardown support?
Already asked this on Stackoverflow AND Reddit, but no one seems to know.
I've been trying to solve the problem for the past 3 days now, but no matter what I try, the types don't compose elegantly.
@saurabhnanda have you looked at Test.QuickCheck.Monadic.monadicIO? Here's a little example:
example :: Integer -> Property
example x = monadicIO $ do
_ <- run $ do
print x
-- this is all in IO, so you could connect to a database,
-- and do whatever you want
assert True
@reiddraper do take a look at http://stackoverflow.com/a/38684717/534481 ? Isn't that a better way?
@saurabhnanda yeah, looks like that should work fine, too. I was only intending to show a basic example of performing IO during a test.
http://stackoverflow.com/a/38684717/534481 looks good to me. Unfortunately there is currently no way to associate setup/teardown code with a property, so indeed you have to create the database connection outside of QuickCheck and pass it to your properties.