| Copyright | (c) Paolo Veronelli Pavlo Kerestey 2017 |
|---|---|
| License | BSD3 |
| Maintainer | paolo.veronelli@gmail.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Test.BDD.Language
Description
The constrained language to define behaviors in BDD terminology
exampleL :: TestTree
exampleL = testBehavior "Test sequence"
$ Given (print "Some effect")
$ Given (print "Another effect")
$ GivenAndAfter (print "Aquiring resource" >> return "Resource 1")
(print . ("Release "++))
$ GivenAndAfter (print "Aquiring resource" >> return "Resource 2")
(print . ("Release "++))
$ When (print "Action returning" >> return ([1..10]++[100..106]) :: IO [Int])
$ Then (@?= ([1..10]++[700..706]))
$ End
Synopsis
- 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
- type BDDPreparing (m :: Type -> Type) t q = Language m t q 'Preparing
- type BDDTesting (m :: Type -> Type) t q = Language m t q 'Testing
- data BDDTest (m :: Type -> Type) t q = BDDTest {
- _tests :: [t -> m q]
- _context :: [TestContext m]
- _when :: m t
- data TestContext (m :: Type -> Type) = TestContext (m r) (r -> m ())
- context :: forall f (m :: Type -> Type) t q. Functor f => ([TestContext m] -> f [TestContext m]) -> BDDTest m t q -> f (BDDTest m t q)
- whenAction :: Functor f => (m t -> f (m t)) -> BDDTest m t q -> f (BDDTest m t q)
- tests :: Functor f => ([t -> m q1] -> f [t -> m q2]) -> BDDTest m t q1 -> f (BDDTest m t q2)
- interpret :: forall (m :: Type -> Type) t q (a :: Phase). Monad m => Language m t q a -> BDDTest m t q
- data Phase
Documentation
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 |
type BDDPreparing (m :: Type -> Type) t q = Language m t q 'Preparing Source #
Preparing language types
data BDDTest (m :: Type -> Type) t q Source #
Result of this module interpreter
Constructors
| BDDTest | |
Fields
| |
Instances
| (Typeable t, TestableMonad m) => IsTest (BDDTest m t ()) | any testable monad can make a BDDTest a tasty test |
Defined in Test.Tasty.Bdd | |
data TestContext (m :: Type -> Type) Source #
Recording given actions and type related teardowns
Constructors
| TestContext (m r) (r -> m ()) |
context :: forall f (m :: Type -> Type) t q. Functor f => ([TestContext m] -> f [TestContext m]) -> BDDTest m t q -> f (BDDTest m t q) Source #
Lens for the ordered preparation actions and their teardowns.
whenAction :: Functor f => (m t -> f (m t)) -> BDDTest m t q -> f (BDDTest m t q) Source #
Lens for the action whose result is supplied to the assertions.
Named whenAction so that it can be imported unqualified next to
Control.Monad.when.
tests :: Functor f => ([t -> m q1] -> f [t -> m q2]) -> BDDTest m t q1 -> f (BDDTest m t q2) Source #
Lens for the assertions, allowing their result type to change.