Add a way to run IO before tests (but only if tests are going to run) #26

ocharles opened this Issue Nov 13, 2012 · 4 comments


None yet

2 participants

I currently have:

main :: IO ()
main = cleanState >> defaultMain tests

So I can make sure that I have a clean state before running integration tests. However, this runs even if I'm just running with --help. Ideally, this would only run if tests are actually going to run.


You could define tests as:

tests = buildTest (cleanState >> return old_tests)

Does that work?

ocharles commented Dec 6, 2012

I actually had to do

main :: IO ()
main = defaultMain [buildTest (cleanState >> return (testGroup "All tests" tests))]

But that does work. I dunno if I lose anything by having to create that top level testGroup, but it seems fine.


Yeah sorry about that top-level test group. Perhaps I should add a way to build an "anonymous" test group, i.e. a combinator of type :: [Test] -> Test.

ocharles commented Dec 6, 2012

I would be happy with that, but this is also fine. Your call! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment