Copyright | (c) Paolo Veronelli Pavlo Kerestey 2017 |
---|---|
License | BSD3 |
Maintainer | paolo.veronelli@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
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 t q a where
- Given :: m () -> Language m t q Preparing -> Language m t q Preparing
- GivenAndAfter :: m r -> (r -> m ()) -> Language m t q Preparing -> Language m t q Preparing
- When :: m t -> Language m t q Testing -> Language m t q Preparing
- Then :: (t -> m q) -> Language m t q Testing -> Language m t q Testing
- End :: Language m t q Testing
- type BDDPreparing m t q = Language m t q Preparing
- type BDDTesting m t q = Language m t q Testing
- data BDDTest m t q = BDDTest {
- _tests :: [t -> m q]
- _context :: [TestContext m]
- _when :: m t
- data TestContext m = TestContext (m r) (r -> m ())
- context :: forall m t q. Lens' (BDDTest m t q) [TestContext m]
- when :: forall m t q. Lens' (BDDTest m t q) (m t)
- tests :: forall m t q q. Lens (BDDTest m t q) (BDDTest m t q) [t -> m q] [t -> m q]
- interpret :: Monad m => Language m t q a -> BDDTest m t q
- data Phase
Documentation
data Language m t q a where Source #
Bare hoare language
Given :: m () -> Language m t q Preparing -> Language m t q Preparing | action to prepare the test |
GivenAndAfter :: m r -> (r -> m ()) -> Language m t q Preparing -> Language m t q Preparing | action to prepare the test, and related teardown action |
When :: m t -> Language m t q Testing -> Language m t q Preparing | core logic of the test (last preparing action) |
Then :: (t -> m q) -> Language m t q Testing -> Language m t q Testing | action producing a test |
End :: Language m t q Testing | final placeholder |
type BDDPreparing m t q = Language m t q Preparing Source #
Preparing language types
type BDDTesting m t q = Language m t q Testing Source #
Testing language types
Result of this module interpreter
BDDTest | |
|
Instances
(Typeable t, TestableMonad m) => IsTest (BDDTest m t ()) Source # | any testable monad can make a BDDTest a tasty test |
Defined in Test.Tasty.Bdd |
data TestContext m Source #
Recording given actions and type related teardowns
TestContext (m r) (r -> m ()) |