| Safe Haskell | None |
|---|
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.
- htfMain :: TestableHTF t => t -> IO ()
- runTest :: TestableHTF t => t -> IO ExitCode
- runTestWithArgs :: TestableHTF t => [String] -> t -> IO ExitCode
- runTestWithOptions :: TestableHTF t => TestOptions -> t -> IO ExitCode
- data TestOptions = TestOptions {
- opts_quiet :: Bool
- opts_filter :: Filter
- opts_help :: Bool
- opts_negated :: [String]
- defaultTestOptions :: TestOptions
- parseTestArgs :: [String] -> Either String TestOptions
- type TestID = String
- type Assertion = IO ()
- data Test
- data TestSuite
- type Filter = FlatTest -> Bool
- data FlatTest = FlatTest TestSort TestID (Maybe Location) Assertion
- data TestSort
- class TestableHTF t
- makeQuickCheckTest :: TestID -> Location -> Assertion -> Test
- makeUnitTest :: TestID -> Location -> IO a -> Test
- makeBlackBoxTest :: TestID -> Assertion -> Test
- makeTestSuite :: TestID -> [Test] -> TestSuite
- makeAnonTestSuite :: [Test] -> TestSuite
- addToTestSuite :: TestSuite -> [Test] -> TestSuite
- testSuiteAsTest :: TestSuite -> Test
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.
Arguments
| :: TestableHTF t | |
| => t | Testable thing |
| -> IO ExitCode |
Run something testable using the defaultTestOptions.
Arguments
| :: TestableHTF t | |
| => [String] | Commandline arguments |
| -> t | Testable thing |
| -> IO ExitCode | See |
Run something testable, parse the TestOptions from the given commandline arguments.
runTestWithOptions :: TestableHTF t => TestOptions -> t -> IO ExitCodeSource
Runs something testable with the given TestOptions.
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.
Options for running tests
data TestOptions Source
Options for running tests.
Constructors
| TestOptions | |
Fields
| |
defaultTestOptions :: TestOptionsSource
The default TestOptions:
TestOptions {
opts_quiet = False
, opts_filter = const True
, opts_help = False
, opts_negated = []
}
parseTestArgs :: [String] -> Either String TestOptionsSource
Parse commandline arguments into TestOptions. Here's a synopsis
of the format of the commandline arguments:
[OPTION ...] TEST_PATTERN ... where TEST_PATTERN is a posix regular expression matching the names of the tests to run. -v --verbose chatty output -q --quiet only display errors -n TEST_PATTERN --not=TEST_PATTERN tests to exclude -h --help display this message
Organzing tests
Type for flattened tests.
Type for distinguishing different sorts of tests.
Constructors
| UnitTest | |
| QuickCheckTest | |
| BlackBoxTest |
class TestableHTF t Source
A type class for things that can be run as tests. Mainly used internally.
Instances
| TestableHTF TestSuite | |
| TestableHTF Test | |
| TestableHTF t => TestableHTF [t] | |
| TestableHTF (IO a) |
makeQuickCheckTest :: TestID -> Location -> Assertion -> TestSource
Construct a test where the given Assertion checks a quick check property.
See QuickCheckWrapper.
Mainly used internally.
makeUnitTest :: TestID -> Location -> IO a -> TestSource
Construct a unit test from the given IO action.
See HUnitWrapper.
Mainly used internally.
makeBlackBoxTest :: TestID -> Assertion -> TestSource
Construct a black box test from the given Assertion.
See BlackBoxTest.
Mainly used internally.
makeTestSuite :: TestID -> [Test] -> TestSuiteSource
makeAnonTestSuite :: [Test] -> TestSuiteSource
addToTestSuite :: TestSuite -> [Test] -> TestSuiteSource