tasty-bdd
Copyright(c) Paolo Veronelli Pavlo Kerestey 2017-2020
LicenseBSD-3-Clause
Maintainerpaolo.veronelli@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Bdd

Description

Tasty driver for Language

Synopsis

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 Phase Source #

Separating the 2 phases by type

Constructors

Preparing 
Testing 

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

testBehavior Source #

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

testBehaviorIO Source #

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 BDDTesting (m :: Type -> Type) t q = Language m t q 'Testing Source #

Testing language types

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

Methods

runCase :: m Result -> IO Result Source #

Instances

Instances details
TestableMonad IO Source # 
Instance details

Defined in Test.Tasty.Bdd

Methods

runCase :: IO Result -> IO Result Source #

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

afterEach :: IO () -> TestTree -> TestTree Source #

recursively append an action

before :: IO () -> TestTree -> TestTree Source #

specialize withResource to prepend an action

after :: IO () -> TestTree -> TestTree Source #

specialize withResource to append an action

onEach :: (TestTree -> TestTree) -> TestTree -> TestTree Source #

recursively modify a TestTree

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.

Orphan instances

(Typeable t, TestableMonad m) => IsTest (BDDTest m t ()) Source #

any testable monad can make a BDDTest a tasty test

Instance details

Methods

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

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