tasty-bdd
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.BDD.LanguageFree

Description

Free monads for composing GivenWhenThen scenarios.

Module : Test.BDD.LanguageFree Copyright : (c) Paolo Veronelli 2017 License : BSD-3-Clause Maintainer: paolo.veronelli@gmail.com Stability : experimental Portability: non-portable

Synopsis

Documentation

given :: m a -> Free (GivenFree m) a Source #

Run a preparation action and return its value to subsequent steps.

givenAndAfter_ :: Functor m => m r -> (r -> m ()) -> Free (GivenFree m) () Source #

Acquire a resource and record its teardown without returning a value.

givenAndAfter :: m (b, r) -> (r -> m ()) -> Free (GivenFree m) b Source #

Acquire a value and resource, recording the resource teardown.

then_ :: (t -> m ()) -> Free (ThenFree m t) () Source #

Add an assertion using the scenario action result.

then__ :: m () -> Free (ThenFree m t) () Source #

Add an assertion independent of the scenario action result.

when_ :: m t -> Free (ThenFree m t) b -> Free (GivenFree m) () Source #

Run the scenario action and feed its result to the assertions.

data GivenFree (m :: Type -> Type) a Source #

Preparation instructions for the free-monad interface.

Instances

Instances details
Functor (GivenFree m) Source # 
Instance details

Defined in Test.BDD.LanguageFree

Methods

fmap :: (a -> b) -> GivenFree m a -> GivenFree m b #

(<$) :: a -> GivenFree m b -> GivenFree m a #

data ThenFree (m :: Type -> Type) t a Source #

Assertions that consume the result of a scenario action.

Instances

Instances details
Functor (ThenFree m t) Source # 
Instance details

Defined in Test.BDD.LanguageFree

Methods

fmap :: (a -> b) -> ThenFree m t a -> ThenFree m t b #

(<$) :: a -> ThenFree m t b -> ThenFree m t a #

type FreeBDD (m :: Type -> Type) x = Free (GivenFree m) x Source #

A scenario built from preparation instructions.

testFreeBDD :: MonadCatch m => Free (GivenFree m) x -> m (BDDResult m) Source #

Execute a scenario and return its result with recorded teardown.

data BDDResult (m :: Type -> Type) Source #

A scenario result carrying the recorded teardown action.

Constructors

Failed SomeException (m ()) 
Succeded (m ())