prop-unit-0.1.2: Conveniences for using Hedgehog as a unit test runner
Safe HaskellSafe-Inferred
LanguageHaskell2010

PropUnit

Synopsis

Documentation

data DependencyType #

These are the two ways in which one test may depend on the others.

This is the same distinction as the hard vs soft dependencies in TestNG.

Since: tasty-1.2

Constructors

AllSucceed

The current test tree will be executed after its dependencies finish, and only if all of the dependencies succeed.

AllFinish

The current test tree will be executed after its dependencies finish, regardless of whether they succeed or not.

Instances

Instances details
Show DependencyType 
Instance details

Defined in Test.Tasty.Core

Eq DependencyType 
Instance details

Defined in Test.Tasty.Core

type Gen = GenT Identity #

Generator for random values of a.

class Monad m => MonadTest (m :: Type -> Type) #

Minimal complete definition

liftTest

Instances

Instances details
Monad m => MonadTest (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> PropertyT m a #

Monad m => MonadTest (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> TestT m a #

MonadTest m => MonadTest (ResourceT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ResourceT m a #

MonadTest m => MonadTest (MaybeT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> MaybeT m a #

MonadTest m => MonadTest (ExceptT x m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ExceptT x m a #

MonadTest m => MonadTest (IdentityT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> IdentityT m a #

MonadTest m => MonadTest (ReaderT r m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ReaderT r m a #

MonadTest m => MonadTest (StateT s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> StateT s m a #

MonadTest m => MonadTest (StateT s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> StateT s m a #

(MonadTest m, Monoid w) => MonadTest (WriterT w m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> WriterT w m a #

(MonadTest m, Monoid w) => MonadTest (WriterT w m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> WriterT w m a #

MonadTest m => MonadTest (ContT r m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ContT r m a #

(MonadTest m, Monoid w) => MonadTest (RWST r w s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> RWST r w s m a #

(MonadTest m, Monoid w) => MonadTest (RWST r w s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> RWST r w s m a #

data Property #

A property test, along with some configurable limits like how many times to run the test.

data PropertyT (m :: Type -> Type) a #

The property monad transformer allows both the generation of test inputs and the assertion of expectations.

Instances

Instances details
MonadTransDistributive PropertyT 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type Transformer f PropertyT m #

Methods

distributeT :: forall f (m :: Type -> Type) a. Transformer f PropertyT m => PropertyT (f m) a -> f (PropertyT m) a #

MonadTrans PropertyT 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: Monad m => m a -> PropertyT m a #

MFunctor PropertyT 
Instance details

Defined in Hedgehog.Internal.Property

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> PropertyT m b -> PropertyT n b #

MonadBaseControl b m => MonadBaseControl b (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type StM (PropertyT m) a #

Methods

liftBaseWith :: (RunInBase (PropertyT m) b -> b a) -> PropertyT m a #

restoreM :: StM (PropertyT m) a -> PropertyT m a #

MonadError e m => MonadError e (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

throwError :: e -> PropertyT m a #

catchError :: PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a #

MonadReader r m => MonadReader r (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

ask :: PropertyT m r #

local :: (r -> r) -> PropertyT m a -> PropertyT m a #

reader :: (r -> a) -> PropertyT m a #

MonadState s m => MonadState s (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

get :: PropertyT m s #

put :: s -> PropertyT m () #

state :: (s -> (a, s)) -> PropertyT m a #

MonadBase b m => MonadBase b (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftBase :: b α -> PropertyT m α #

Monad m => MonadFail (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

fail :: String -> PropertyT m a #

MonadIO m => MonadIO (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftIO :: IO a -> PropertyT m a #

MonadPlus m => Alternative (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

empty :: PropertyT m a #

(<|>) :: PropertyT m a -> PropertyT m a -> PropertyT m a #

some :: PropertyT m a -> PropertyT m [a] #

many :: PropertyT m a -> PropertyT m [a] #

Monad m => Applicative (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

pure :: a -> PropertyT m a #

(<*>) :: PropertyT m (a -> b) -> PropertyT m a -> PropertyT m b #

liftA2 :: (a -> b -> c) -> PropertyT m a -> PropertyT m b -> PropertyT m c #

(*>) :: PropertyT m a -> PropertyT m b -> PropertyT m b #

(<*) :: PropertyT m a -> PropertyT m b -> PropertyT m a #

Functor m => Functor (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

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

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

Monad m => Monad (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

(>>=) :: PropertyT m a -> (a -> PropertyT m b) -> PropertyT m b #

(>>) :: PropertyT m a -> PropertyT m b -> PropertyT m b #

return :: a -> PropertyT m a #

MonadPlus m => MonadPlus (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

mzero :: PropertyT m a #

mplus :: PropertyT m a -> PropertyT m a -> PropertyT m a #

MonadCatch m => MonadCatch (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

catch :: Exception e => PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a #

MonadThrow m => MonadThrow (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

throwM :: Exception e => e -> PropertyT m a #

Monad m => MonadTest (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> PropertyT m a #

PrimMonad m => PrimMonad (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (PropertyT m) #

Methods

primitive :: (State# (PrimState (PropertyT m)) -> (# State# (PrimState (PropertyT m)), a #)) -> PropertyT m a #

MonadResource m => MonadResource (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftResourceT :: ResourceT IO a -> PropertyT m a #

type Transformer t PropertyT m 
Instance details

Defined in Hedgehog.Internal.Property

type PrimState (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

type StM (PropertyT m) a 
Instance details

Defined in Hedgehog.Internal.Property

type StM (PropertyT m) a = StM (TestT (GenT m)) a

data Range a #

A range describes the bounds of a number to generate, which may or may not be dependent on a Size.

The constructor takes an origin between the lower and upper bound, and a function from Size to bounds. As the size goes towards 0, the values go towards the origin.

Instances

Instances details
Functor Range 
Instance details

Defined in Hedgehog.Internal.Range

Methods

fmap :: (a -> b) -> Range a -> Range b #

(<$) :: a -> Range b -> Range a #

data TestLimit #

The number of successful tests that need to be run before a property test is considered successful.

Can be constructed using numeric literals:

  200 :: TestLimit

Instances

Instances details
Enum TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Num TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Integral TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Real TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Show TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Eq TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Ord TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Lift TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: Quote m => TestLimit -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => TestLimit -> Code m TestLimit #

type TestName = String #

The name of a test or a group of tests

data TestTree #

The main data structure defining a test suite.

It consists of individual test cases and properties, organized in named groups which form a tree-like hierarchy.

There is no generic way to create a test case. Instead, every test provider (tasty-hunit, tasty-smallcheck etc.) provides a function to turn a test case into a TestTree.

Groups can be created using testGroup.

(===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 #

Fails the test if the two arguments provided are not equal.

(/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 #

Fails the test if the two arguments provided are equal.

after #

Arguments

:: DependencyType

whether to run the tests even if some of the dependencies fail

-> String

the pattern

-> TestTree

the subtree that depends on other tests

-> TestTree

the subtree annotated with dependency information

The after combinator declares dependencies between tests.

If a TestTree is wrapped in after, the tests in this tree will not run until certain other tests («dependencies») have finished. These dependencies are specified using an AWK pattern (see the «Patterns» section in the README).

Moreover, if the DependencyType argument is set to AllSucceed and at least one dependency has failed, this test tree will not run at all.

Tasty does not check that the pattern matches any tests (let alone the correct set of tests), so it is on you to supply the right pattern.

Examples

Expand

The following test will be executed only after all tests that contain Foo anywhere in their path finish.

after AllFinish "Foo" $
   

testCase "A test that depends on Foo.Bar" $ ...

Note, however, that our test also happens to contain Foo as part of its name, so it also matches the pattern and becomes a dependency of itself. This will result in a DependencyLoop exception. To avoid this, either change the test name so that it doesn't mention Foo or make the pattern more specific.

You can use AWK patterns, for instance, to specify the full path to the dependency.

after AllFinish "$0 == \"Tests.Foo.Bar\"" $
   

testCase "A test that depends on Foo.Bar" $ ...

Or only specify the dependency's own name, ignoring the group names:

after AllFinish "$NF == \"Bar\"" $
   

testCase "A test that depends on Foo.Bar" $ ...

Since: tasty-1.2

assert :: (MonadTest m, HasCallStack) => Bool -> m () #

Fails the test if the condition provided is False.

forAll :: forall (m :: Type -> Type) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a #

Generates a random input for the test by running the provided generator.

testGroup :: TestName -> [TestTree] -> TestTree #

Create a named group of test cases or other groups

withResource #

Arguments

:: IO a

initialize the resource

-> (a -> IO ())

free the resource

-> (IO a -> TestTree)

IO a is an action which returns the acquired resource. Despite it being an IO action, the resource it returns will be acquired only once and shared across all the tests in the tree.

-> TestTree 

Acquire the resource to run this test (sub)tree and release it afterwards