beforeAll_ Run a custom action before all spec items in a group without setting up any outer resources.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulesydtest-0.22.0.0Haskell2010
This module defines all the functions you will use to define your test suite.
beforeAll_ Run a custom action before all spec items in a group without setting up any outer resources.
beforeAll Run a custom action before all spec items in a group, to set up an outer resource a.
beforeAllWith Run a custom action before all spec items in a group, to set up an outer resource b by using the outer resource a.
afterAll_ Run a custom action after all spec items without using any outer resources.
afterAll Run a custom action after all spec items, using the outer resource a.
afterAll' Run a custom action after all spec items, using all the outer resources.
aroundAll_ Run a custom action before and/or after all spec items in a group without accessing any resources.
This combinator gives the programmer a lot of power. In fact, it gives the programmer enough power to break the test framework. Indeed, you can provide a wrapper function that just _doesn't_ run the function like this:
spec :: Spec
spec = do
let don'tDo :: IO () -> IO ()
don'tDo _ = pure ()
aroundAll_ don'tDo $ do
it "should pass" TrueDuring execution, you'll then get an error like this:
thread blocked indefinitely in an MVar operationThe same problem exists when using around_.
Something even more pernicious goes wrong when you run the given action more than once like this:
spec :: Spec
spec = do
let doTwice :: IO () -> IO ()
doTwice f = f >> f
aroundAll_ doTwice $ do
it "should pass" TrueIn this case, the test will "just work", but it will be executed twice even if the output reports that it only passed once.
Note: If you're interested in fixing this, talk to me, but only after GHC has gotten impredicative types because that will likely be a requirement.
aroundAll Run a custom action before and/or after all spec items in group, to provide access to a resource a.
See the FOOTGUN note in the docs for around_.
aroundAllWith Run a custom action before and/or after all spec items in a group to
provide access to a resource a while using a resource b
See the FOOTGUN note in the docs for around_.
aroundAllWithAll Run a custom action before and/or after all spec items in a group to
provide access to a resource a while using all outer resources.
wrapForest :: (TestForest outers1 inner1 -> TestTree outers2 inner2)The wrapper node
-> TestDefM outers1 inner1 result-> TestDefM outers2 inner2 resultDeclare a node in the spec def forest