| Copyright | (c) Paolo Veronelli Pavlo Kerestey 2017-2020 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | paolo.veronelli@gmail.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Test.Tasty.Bdd
Contents
Description
Tasty driver for Language
Synopsis
- (@?=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => a -> a -> m ()
- (@?/=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => a -> a -> m ()
- (^?=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => m a -> a -> b -> m ()
- (^?/=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => m a -> a -> b -> m ()
- acquire :: MonadIO m => IO a -> (m a -> TestTree) -> TestTree
- acquirePure :: IO a -> (a -> TestTree) -> TestTree
- data Phase
- data Language (m :: Type -> Type) t q (a :: Phase) where
- Given :: forall (m :: Type -> Type) t q. m () -> Language m t q 'Preparing -> Language m t q 'Preparing
- GivenAndAfter :: forall (m :: Type -> Type) r t q. m r -> (r -> m ()) -> Language m t q 'Preparing -> Language m t q 'Preparing
- When :: forall (m :: Type -> Type) t q. m t -> Language m t q 'Testing -> Language m t q 'Preparing
- Then :: forall t (m :: Type -> Type) q. (t -> m q) -> Language m t q 'Testing -> Language m t q 'Testing
- End :: forall (m :: Type -> Type) t q. Language m t q 'Testing
- testBehavior :: forall (m :: Type -> Type) t. (MonadIO m, TestableMonad m, Typeable t) => String -> BDDPreparing m t () -> TestTree
- testBehaviorIO :: forall t (m :: Type -> Type). (Typeable t, MonadIO m, TestableMonad m) => String -> IO (BDDPreparing m t ()) -> TestTree
- type BDDTesting (m :: Type -> Type) t q = Language m t q 'Testing
- type BDDPreparing (m :: Type -> Type) t q = Language m t q 'Preparing
- class (MonadCatch m, MonadIO m, Monad m, Typeable m) => TestableMonad (m :: Type -> Type) where
- failFastIngredients :: [Ingredient]
- failFastTester :: TestTree -> IO ()
- prettyDifferences :: ToExpr a => a -> a -> String
- beforeEach :: IO () -> TestTree -> TestTree
- afterEach :: IO () -> TestTree -> TestTree
- before :: IO () -> TestTree -> TestTree
- after :: IO () -> TestTree -> TestTree
- onEach :: (TestTree -> TestTree) -> TestTree -> TestTree
- captureStdout :: String -> IO () -> IO Text
- testBehaviorF :: (Typeable m, MonadCatch m) => (m Result -> IO Result) -> String -> FreeBDD m x -> TestTree
Documentation
(@?=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => a -> a -> m () infixl 4 Source #
equality test which show pretty differences on fail
(@?/=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => a -> a -> m () Source #
inequality test which show pretty differences on fail
(^?=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => m a -> a -> b -> m () Source #
shortcut to ignore the input and run another action instead in Then matching equality
(^?/=) :: (ToExpr a, Eq a, Typeable a, MonadThrow m) => m a -> a -> b -> m () Source #
shortcut to ignore the input and run another action instead in Then matching inequality
acquire :: MonadIO m => IO a -> (m a -> TestTree) -> TestTree Source #
specialize withResource to just acquire a resource
acquirePure :: IO a -> (a -> TestTree) -> TestTree Source #
Acquire a resource and expose its value through the resource callback.
data Language (m :: Type -> Type) t q (a :: Phase) where Source #
Bare hoare language
Constructors
| Given :: forall (m :: Type -> Type) t q. m () -> Language m t q 'Preparing -> Language m t q 'Preparing | action to prepare the test |
| GivenAndAfter :: forall (m :: Type -> Type) r t q. m r -> (r -> m ()) -> Language m t q 'Preparing -> Language m t q 'Preparing | action to prepare the test, and related teardown action |
| When :: forall (m :: Type -> Type) t q. m t -> Language m t q 'Testing -> Language m t q 'Preparing | core logic of the test (last preparing action) |
| Then :: forall t (m :: Type -> Type) q. (t -> m q) -> Language m t q 'Testing -> Language m t q 'Testing | action producing a test |
| End :: forall (m :: Type -> Type) t q. Language m t q 'Testing | final placeholder |
Arguments
| :: forall (m :: Type -> Type) t. (MonadIO m, TestableMonad m, Typeable t) | |
| => String | test name |
| -> BDDPreparing m t () | bdd test definition |
| -> TestTree | resulting tasty test |
interpret a Language scenario to a single TestTree
Arguments
| :: forall t (m :: Type -> Type). (Typeable t, MonadIO m, TestableMonad m) | |
| => String | test name |
| -> IO (BDDPreparing m t ()) | bdd test definition |
| -> TestTree | resulting tasty test |
Acquire a constructor-based scenario in IO and adapt it to Tasty.
type BDDPreparing (m :: Type -> Type) t q = Language m t q 'Preparing Source #
Preparing language types
class (MonadCatch m, MonadIO m, Monad m, Typeable m) => TestableMonad (m :: Type -> Type) where Source #
testable monads can map to IO a Tasty Result
Instances
failFastIngredients :: [Ingredient] Source #
basic ingredients fail-fast aware
failFastTester :: TestTree -> IO () Source #
default test runner fail-fast aware
prettyDifferences :: ToExpr a => a -> a -> String Source #
show a coloured difference of 2 values
beforeEach :: IO () -> TestTree -> TestTree Source #
recursively prepend an action
captureStdout :: String -> IO () -> IO Text Source #
Capture output using a temporary file. Concurrent captures are not isolated.
testBehaviorF :: (Typeable m, MonadCatch m) => (m Result -> IO Result) -> String -> FreeBDD m x -> TestTree Source #
Adapt a free-monad scenario to Tasty using a runner for its monad.