Tasty 1.2 supports dependencies between tests
Published on
Tasty (GitHub, Hackage) is a versatile and extensible testing framework for Haskell. Using tasty, you can quickly create a test suite consisting of unit tests, property tests and golden tests. Users of tasty benefit from automatic parallelism, a rich filtering language to choose which tests to run, sharing resources between tests and more.
Tasty 1.2 adds another long-awaited feature: dependencies between tests. If the tests only ran sequentially, dependencies wouldn’t be an issue: you could always arrange your tests in the desired order.
However, tasty runs all tests in parallel by default (using a user-specified or automatically determined number of worker threads). While it’s always been possible to force sequential execution by setting the number of threads to 1, sometimes you want to take advantage of the parallelism while also making sure that some tests run after some other tests due to the tests’ side effects.
This is now possible using the after
combinator:
"Tests accessing the same resource"
testGroup "Test A" $ ...
[ testCase AllFinish "Test A" $
, after "Test B" $ ...
testCase ]
In this example, Test B will only start running after Test A has
finished—successfully or not. Alternatively, you can tell Test B to run
only when Test A succeeds (notice AllSucceed
instead of
AllFinish
):
"Tests creating and using a resource"
testGroup "Test A" $ ...
[ testCase AllSucceed "Test A" $
, after "Test B" $ ...
testCase ]
The "Test A"
argument of after
in these
examples is not simply a test name—it is a pattern in tasty’s AWK-like
pattern language, so a test can depend simultaneously on a combination
of different tests from different subtrees.
To learn more about dependencies in tasty, please refer to the README and the haddock documentation.