Test.Framework.TestManager

Description

This module defines function for running a set of tests. Furthermore, it provides functionality for organzing tests into a hierarchical structure. This functionality is mainly used internally in the code generated by the hftpp pre-processor.

Synopsis

Running tests

htfMain :: TestableHTF t => t -> IO () Source #

Runs something testable by parsing the commandline arguments as test options (using parseTestArgs). Exits with the exit code returned by runTestWithArgs. This function is the main entry point for running tests.

htfMainWithArgs :: TestableHTF t => [String] -> t -> IO () Source #

Runs something testable by parsing the commandline arguments as test options (using parseTestArgs). Exits with the exit code returned by runTestWithArgs.

Arguments

 :: TestableHTF t => t Testable thing -> IO ExitCode See runTestWithOptions for a specification of the ExitCode result

Run something testable using the defaultCmdlineOptions.

Arguments

 :: TestableHTF t => t Testable thing -> IO (IO (), ExitCode) IO action for printing the overall test results, and exit code for the test run. See runTestWithOptions for a specification of the ExitCode result

Run something testable using the defaultCmdlineOptions.

Arguments

 :: TestableHTF t => [String] Commandline arguments -> t Testable thing -> IO ExitCode See runTestWithConfig for a specification of the ExitCode result.

Run something testable, parse the CmdlineOptions from the given commandline arguments. Does not print the overall test results but returns an IO action for doing so.

Arguments

 :: TestableHTF t => [String] Commandline arguments -> t Testable thing -> IO (IO (), ExitCode) IO action for printing the overall test results, and exit code for the test run. See runTestWithConfig for a specification of the ExitCode result.

Run something testable, parse the CmdlineOptions from the given commandline arguments.

Runs something testable with the given CmdlineOptions. See runTestWithConfig for a specification of the ExitCode result.

runTestWithOptions' :: TestableHTF t => CmdlineOptions -> t -> IO (IO (), ExitCode) Source #

Runs something testable with the given CmdlineOptions. Does not print the overall test results but returns an IO action for doing so. See runTestWithConfig for a specification of the ExitCode result.

Runs something testable with the given TestConfig. The result is ExitSuccess if all tests were executed successfully, ExitFailure otherwise. In the latter case, an error code of 1 indicates that failures but no errors occurred, otherwise the error code 2 is used.

A test is successful if the test terminates and no assertion fails. A test is said to fail if an assertion fails but no other error occur.

runTestWithConfig' :: TestableHTF t => TestConfig -> t -> IO (IO (), ExitCode, TestHistory) Source #

Runs something testable with the given TestConfig. Does not print the overall test results but returns an IO action for doing so. See runTestWithConfig for a specification of the ExitCode result.

Organzing tests

class TestableHTF t Source #

A type class for things that can be run as tests. Mainly used internally.

Minimal complete definition

flatten

Instances
 Source # Instance detailsDefined in Test.Framework.TestManager Methodsflatten :: TestSuite -> [FlatTest] Source # Instance detailsDefined in Test.Framework.TestManager Methodsflatten :: Test -> [FlatTest] TestableHTF t => TestableHTF [t] Source # Instance detailsDefined in Test.Framework.TestManager Methodsflatten :: [t] -> [FlatTest] Source # Instance detailsDefined in Test.Framework.TestManager Methodsflatten :: IO a -> [FlatTest]

class WrappableHTF t where Source #

Kind of specialised Functor type class for tests, which allows you to modify the Assertions of the WrappableHTF-thing without changing any test code.

E.g. if you want to add timeouts to all tests of a module, you could write:

addTimeout test = timeout 100 test >>= assertJustVerbose "Timeout exceeded"
testsWithTimeouts = wrap addTimeout htf_thisModulesTests

Methods

wrap :: (Assertion -> Assertion) -> t -> t Source #

Instances
 Source # Instance detailsDefined in Test.Framework.TestManager Methodswrap :: (Assertion -> Assertion) -> TestSuite -> TestSuite Source # Source # Instance detailsDefined in Test.Framework.TestManager Methodswrap :: (Assertion -> Assertion) -> Test -> Test Source #

Construct a test where the given Assertion checks a quick check property. Mainly used internally by the htfpp preprocessor.

Construct a unit test from the given IO action. Mainly used internally by the htfpp preprocessor.

Construct a black box test from the given Assertion. Mainly used internally.

makeTestSuite :: TestID -> [Test] -> TestSuite Source #

Create a named TestSuite from a list of Test values.

Create an unnamed TestSuite from a list of Test values.

Extend a TestSuite with a list of Test values

Turn a TestSuite into a proper Test.