HTF-0.11.1.0: The Haskell Test Framework

Safe HaskellNone

Test.Framework.TestTypes

Contents

Description

This module defines types (and small auxiliary functions) for organizing tests, for configuring the execution of tests, and for representing and reporting their results.

Synopsis

Organizing 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 and their results.

Instances

data TestOptions Source

General options for tests

Constructors

TestOptions 

Fields

to_parallel :: Bool
 

data TestSuite Source

Abstract type for test suites and their results.

data TestSort Source

Type for distinguishing different sorts of tests.

data TestPath Source

A type denoting the hierarchical name of a test.

Instances

data GenFlatTest a Source

Generic type for flattened tests and their results.

Constructors

FlatTest 

Fields

ft_sort :: TestSort

The sort of the test.

ft_path :: TestPath

Hierarchival path.

ft_location :: Maybe Location

Place of definition.

ft_payload :: a

A generic payload.

type FlatTest = GenFlatTest (WithTestOptions Assertion)Source

Flattened representation of tests.

type TestFilter = FlatTest -> BoolSource

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

testPathToList :: TestPath -> [Maybe TestID]Source

Splits a TestPath into a list of test identifiers.

flatName :: TestPath -> StringSource

Creates a string representation from a TestPath.

finalName :: TestPath -> StringSource

Returns the final name of a TestPath

prefixName :: TestPath -> StringSource

Returns the name of the prefix of a test path. The prefix is everything except the last element.

withOptions :: (TestOptions -> TestOptions) -> a -> WithTestOptions aSource

Shortcut for constructing a WithTestOptions value.

Executing tests

type TR = RWST TestConfig () TestState IOSource

The TR (test runner) monad.

data TestState Source

The state type for the TR monad.

Constructors

TestState 

Fields

ts_results :: [FlatTestResult]

Results collected so far.

ts_index :: Int

Current index for splitted output.

initTestState :: TestStateSource

The initial test state.

data TestConfig Source

Configuration of test execution.

Constructors

TestConfig 

Fields

tc_quiet :: Bool

If set, displays messages only for failed tests.

tc_threads :: Maybe Int

Use Just i for parallel execution with i threads, Nothing for sequential execution.

tc_shuffle :: Bool

Shuffle tests before parallel execution

tc_output :: TestOutput

Output destination of progress and result messages.

tc_outputXml :: Maybe FilePath

Output destination of XML result summary

tc_filter :: TestFilter

Filter for the tests to run.

tc_reporters :: [TestReporter]

Test reporters to use.

tc_useColors :: Bool

Whether to use colored output

Instances

data TestOutput Source

The destination of progress and result messages from HTF.

Constructors

TestOutputHandle Handle Bool

Output goes to Handle, boolean flag indicates whether the handle should be closed at the end.

TestOutputSplitted FilePath

Output goes to files whose names are derived from FilePath by appending a number to it. Numbering starts at zero.

Reporting results

type ReportAllTests = [FlatTest] -> TR ()Source

Reports the IDs of all tests available.

type ReportGlobalStart = [FlatTest] -> TR ()Source

Signals that test execution is about to start.

type ReportTestStart = FlatTest -> TR ()Source

Reports the start of a single test.

type ReportTestResult = FlatTestResult -> TR ()Source

Reports the result of a single test.

type ReportGlobalResultsSource

Arguments

 = Milliseconds

wall time in ms

-> [FlatTestResult]

passed tests

-> [FlatTestResult]

pending tests

-> [FlatTestResult]

failed tests

-> [FlatTestResult]

erroneous tests

-> TR () 

Reports the overall results of all tests.

data TestReporter Source

A TestReporter provides hooks to customize the output of HTF.

Constructors

TestReporter 

Fields

tr_id :: String
 
tr_reportAllTests :: ReportAllTests

Called to report the IDs of all tests available.

tr_reportGlobalStart :: ReportGlobalStart

Called to report the start of test execution.

tr_reportTestStart :: ReportTestStart

Called to report the start of a single test.

tr_reportTestResult :: ReportTestResult

Called to report the result of a single test.

tr_reportGlobalResults :: ReportGlobalResults

Called to report the overall results of all tests.

attachCallStack :: ColorString -> CallStack -> ColorStringSource

type CallStack = [(Maybe String, Location)]Source

A type for call-stacks

Specifying results.

data TestResult Source

The summary result of a test.

Constructors

Pass 
Pending 
Fail 
Error 

type FlatTestResult = GenFlatTest RunResultSource

The result of running a FlatTest

type Milliseconds = IntSource

A type synonym for time in milliseconds.

data RunResult Source

The result of a test run.

Constructors

RunResult 

Fields

rr_result :: TestResult

The summary result of the test.

rr_location :: Maybe Location

The location where the test failed (if applicable).

rr_callers :: CallStack

Information about the callers of the location where the test failed

rr_message :: ColorString

A message describing the result.

rr_wallTimeMs :: Milliseconds

Execution time in milliseconds.