HTF-0.9.0.0: The Haskell Test Framework

Safe HaskellNone

Test.Framework.TestManager

Contents

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.

runTestSource

Arguments

:: TestableHTF t 
=> t

Testable thing

-> IO ExitCode 

Run something testable using the defaultTestOptions.

runTestWithArgsSource

Arguments

:: TestableHTF t 
=> [String]

Commandline arguments

-> t

Testable thing

-> IO ExitCode

See runTestWithOptions for a specification of the ExitCode result

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

opts_quiet :: Bool

Be quiet or not.

opts_filter :: Filter

Run only tests matching this filter.

opts_help :: Bool

If True, display a help message and exit.

opts_negated :: [String]

Regular expressions matching test names which should not run.

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 TestID = StringSource

Type for naming tests.

type Assertion = IO ()Source

An assertion is just an IO action.

data Test Source

Abstract type for tests.

Instances

data TestSuite Source

Abstract type for test suites.

type Filter = FlatTest -> BoolSource

A filter is a predicate on FlatTest. If the predicate is True, the flat test is run.

data FlatTest Source

Type for flattened tests.

data TestSort Source

Type for distinguishing different sorts of tests.

class TestableHTF t Source

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

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

Create a named TestSuite from a list of Test values.

makeAnonTestSuite :: [Test] -> TestSuiteSource

Create an unnamed TestSuite from a list of Test values.

addToTestSuite :: TestSuite -> [Test] -> TestSuiteSource

Extend a TestSuite with a list of Test values

testSuiteAsTest :: TestSuite -> TestSource

Turn a TestSuite into a proper Test.