Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- before :: IO inner -> TestDefM outers inner result -> TestDefM outers () result
- before_ :: IO () -> TestDefM outers inner result -> TestDefM outers inner result
- beforeWith :: forall outers oldInner newInner result. (oldInner -> IO newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result
- beforeWith' :: HContains outers outer => (outer -> oldInner -> IO newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result
- after :: (inner -> IO ()) -> TestDefM outers inner result -> TestDefM outers inner result
- after_ :: IO () -> TestDefM outers inner result -> TestDefM outers inner result
- around :: ((inner -> IO ()) -> IO ()) -> TestDefM outers inner result -> TestDefM outers () result
- around_ :: (IO () -> IO ()) -> TestDefM outers inner result -> TestDefM outers inner result
- aroundWith :: forall newInner oldInner outers result. ((newInner -> IO ()) -> oldInner -> IO ()) -> TestDefM outers newInner result -> TestDefM outers oldInner result
- aroundWith' :: forall newInner oldInner outer result (outers :: [Type]). HContains outers outer => ((outer -> newInner -> IO ()) -> outer -> oldInner -> IO ()) -> TestDefM outers newInner result -> TestDefM outers oldInner result
Documentation
:: IO inner | The function to run before every test, to produce the inner resource |
-> TestDefM outers inner result | |
-> TestDefM outers () result |
Run a custom action before every spec item, to set up an inner resource inner
.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
:: IO () | The function to run before every test |
-> TestDefM outers inner result | |
-> TestDefM outers inner result |
Run a custom action before every spec item without setting up any inner resources.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
beforeWith :: forall outers oldInner newInner result. (oldInner -> IO newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #
Run a custom action before every spec item, to set up an inner resource newInner
using the previously set up resource oldInner
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
beforeWith' :: HContains outers outer => (outer -> oldInner -> IO newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #
Run a custom action before every spec item, to set up an inner resource newInner
using the previously set up resource oldInner
and potentially any of the outer resources
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
:: (inner -> IO ()) | The function to run after every test, using the inner resource |
-> TestDefM outers inner result | |
-> TestDefM outers inner result |
Run a custom action after every spec item, using the inner resource c
.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
:: IO () | The function to run after every test |
-> TestDefM outers inner result | |
-> TestDefM outers inner result |
Run a custom action after every spec item without using any inner resources.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
:: ((inner -> IO ()) -> IO ()) | The function to provide the inner resource around every test |
-> TestDefM outers inner result | |
-> TestDefM outers () result |
Run a custom action before and/or after every spec item, to provide access to an inner resource c
.
See the FOOTGUN
note in the docs for around_
.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
:: (IO () -> IO ()) | The function to wrap every test with |
-> TestDefM outers inner result | |
-> TestDefM outers inner result |
Run a custom action before and/or after every spec item without accessing any inner resources.
It is important that the wrapper function that you provide runs the action that it gets _exactly once_.
FOOTGUN
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 () around_ don'tDo $ do it "should pass" True
During execution, you'll then get an error like this:
thread blocked indefinitely in an MVar operation
The same problem exists when using aroundAll_
.
The same thing will go wrong if you run the given action more than once like this:
spec :: Spec spec = do let doTwice :: IO () -> IO () doTwice f = f >> f around_ doTwice $ do it "should pass" True
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.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
aroundWith :: forall newInner oldInner outers result. ((newInner -> IO ()) -> oldInner -> IO ()) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #
Run a custom action before and/or after every spec item, to provide access to an inner resource c
while using the inner resource d
.
See the FOOTGUN
note in the docs for around_
.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331
:: forall newInner oldInner outer result (outers :: [Type]). HContains outers outer | |
=> ((outer -> newInner -> IO ()) -> outer -> oldInner -> IO ()) | The function that provides the new inner resource using the old resource. It can also use and modify the outer resource |
-> TestDefM outers newInner result | |
-> TestDefM outers oldInner result |
Run a custom action around every spec item, to provide access to an inner resource newInner
while using the inner resource oldInner
and any outer resource available.
Note that this function turns off shrinking. See https://github.com/nick8325/quickcheck/issues/331