tasty-bdd
Copyright(c) Paolo Veronelli Pavlo Kerestey 2017
LicenseBSD3
Maintainerpaolo.veronelli@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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

type BDDTesting (m :: Type -> Type) t q = Language m t q 'Testing Source #

Testing language types

data BDDTest (m :: Type -> Type) t q Source #

Result of this module interpreter

Constructors

BDDTest 

Fields

Instances

Instances details
(Typeable t, TestableMonad m) => IsTest (BDDTest m t ())

any testable monad can make a BDDTest a tasty test

Instance details

Defined in Test.Tasty.Bdd

Methods

run :: OptionSet -> BDDTest m t () -> (Progress -> IO ()) -> IO Result

testOptions :: Tagged (BDDTest m t ()) [OptionDescription]

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.

interpret :: forall (m :: Type -> Type) t q (a :: Phase). Monad m => Language m t q a -> BDDTest m t q Source #

An interpreter collecting the actions

data Phase Source #

Separating the 2 phases by type

Constructors

Preparing 
Testing