-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Conveniences for using Hedgehog as a unit test runner -- -- Please see the README on GitHub at -- https://github.com/ejconlon/prop-unit#readme @package prop-unit @version 0.1.1 module PropUnit -- | 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. data DependencyType -- | The current test tree will be executed after its dependencies finish, -- and only if all of the dependencies succeed. AllSucceed :: DependencyType -- | The current test tree will be executed after its dependencies finish, -- regardless of whether they succeed or not. AllFinish :: DependencyType -- | Generator for random values of a. type Gen = GenT Identity class Monad m => MonadTest (m :: Type -> Type) -- | A property test, along with some configurable limits like how many -- times to run the test. data Property -- | The property monad transformer allows both the generation of test -- inputs and the assertion of expectations. data PropertyT (m :: Type -> Type) 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. data Range a -- | 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
--   
data TestLimit -- | The name of a test or a group of tests type TestName = String -- | 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. data TestTree -- | 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. (/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 /== -- | 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" $ ...
--   
after :: DependencyType -> String -> TestTree -> TestTree -- | Fails the test if the condition provided is False. assert :: (MonadTest m, HasCallStack) => Bool -> m () -- | Generates a random input for the test by running the provided -- generator. 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 -- | Create a named group of test cases or other groups testGroup :: TestName -> [TestTree] -> TestTree testMain :: (TestLimit -> TestTree) -> IO () -- | Acquire the resource to run this test (sub)tree and release it -- afterwards withResource :: IO a -> (a -> IO ()) -> (IO a -> TestTree) -> TestTree