Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- withContainers :: forall a. (forall m. MonadDocker m => m a) -> (IO a -> TestTree) -> TestTree
- module TestContainers
Running containers for tests
withContainers :: forall a. (forall m. MonadDocker m => m a) -> (IO a -> TestTree) -> TestTree Source #
Allow TestTree
to depend on Docker containers. Tasty takes care of
initialization and de-initialization of the containers.
containers :: MonadDocker m => m () containers = do _redis <- TestContainers.run $ TestContainers.containerRequest TestContainers.redis _kafka <- TestContainers.run $ TestContainers.containerRequest TestContainers.kafka pure () example :: TestTree example = withContainers containers $ \runContainers -> testGroup "Example tests" [ testCase "first test" $ do -- Actually runs the container. runContainers testCase "second test" $ do -- Start containers. Tasty makes sure to only initialize once as -- `first test` might already have started them. runContainers ]
withContainers
allows you naturally scope the handling of containers for your tests.
Re-exports for convenience
module TestContainers