Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data DependencyType
- type Gen = GenT Identity
- class Monad m => MonadTest (m :: Type -> Type)
- data Property
- data PropertyT (m :: Type -> Type) a
- data Range a
- data TestLimit
- type TestName = String
- data TestTree
- (===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m ()
- (/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m ()
- after :: DependencyType -> String -> TestTree -> TestTree
- assert :: (MonadTest m, HasCallStack) => Bool -> m ()
- forAll :: forall (m :: Type -> Type) a. (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a
- testProp :: TestName -> TestLimit -> PropertyT IO () -> TestTree
- testUnit :: TestName -> PropertyT IO () -> TestTree
- defaultTestLimit :: TestLimit
- setupTests :: IO TestLimit
- testGroup :: TestName -> [TestTree] -> TestTree
- testMain :: (TestLimit -> TestTree) -> IO ()
- withResource :: IO a -> (a -> IO ()) -> (IO a -> TestTree) -> TestTree
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
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
Show DependencyType | |
Defined in Test.Tasty.Core showsPrec :: Int -> DependencyType -> ShowS # show :: DependencyType -> String # showList :: [DependencyType] -> ShowS # | |
Eq DependencyType | |
Defined in Test.Tasty.Core (==) :: DependencyType -> DependencyType -> Bool # (/=) :: DependencyType -> DependencyType -> Bool # |
class Monad m => MonadTest (m :: Type -> Type) #
Instances
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
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
Enum TestLimit | |
Defined in Hedgehog.Internal.Property succ :: TestLimit -> TestLimit # pred :: TestLimit -> TestLimit # fromEnum :: TestLimit -> Int # enumFrom :: TestLimit -> [TestLimit] # enumFromThen :: TestLimit -> TestLimit -> [TestLimit] # enumFromTo :: TestLimit -> TestLimit -> [TestLimit] # enumFromThenTo :: TestLimit -> TestLimit -> TestLimit -> [TestLimit] # | |
Num TestLimit | |
Defined in Hedgehog.Internal.Property | |
Integral TestLimit | |
Defined in Hedgehog.Internal.Property | |
Real TestLimit | |
Defined in Hedgehog.Internal.Property toRational :: TestLimit -> Rational # | |
Show TestLimit | |
Eq TestLimit | |
Ord TestLimit | |
Defined in Hedgehog.Internal.Property | |
Lift TestLimit | |
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.
:: 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
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.
setupTests :: IO TestLimit Source #
:: IO a | initialize the resource |
-> (a -> IO ()) | free the resource |
-> (IO a -> TestTree) |
|
-> TestTree |
Acquire the resource to run this test (sub)tree and release it afterwards