HUnit-1.2.2.1: A unit testing framework for Haskell

Test.HUnit.Text

Description

Text-based test controller for running HUnit tests and reporting results as text, usually to a terminal.

Synopsis

Documentation

data PutText st Source

As the general text-based test controller (runTestText) executes a test, it reports each test case start, error, and failure by constructing a string and passing it to the function embodied in a PutText. A report string is known as a "line", although it includes no line terminator; the function in a PutText is responsible for terminating lines appropriately. Besides the line, the function receives a flag indicating the intended "persistence" of the line: True indicates that the line should be part of the final overall report; False indicates that the line merely indicates progress of the test execution. Each progress line shows the current values of the cumulative test execution counts; a final, persistent line shows the final count values.

The PutText function is also passed, and returns, an arbitrary state value (called st here). The initial state value is given in the PutText; the final value is returned by runTestText.

Constructors

PutText (String -> Bool -> st -> IO st) st 

putTextToHandleSource

Arguments

:: Handle 
-> Bool

Write progress lines to handle?

-> PutText Int 

Two reporting schemes are defined here. putTextToHandle writes report lines to a given handle. putTextToShowS accumulates persistent lines for return as a whole by runTestText.

putTextToHandle writes persistent lines to the given handle, following each by a newline character. In addition, if the given flag is True, it writes progress lines to the handle as well. A progress line is written with no line termination, so that it can be overwritten by the next report line. As overwriting involves writing carriage return and blank characters, its proper effect is usually only obtained on terminal devices.

putTextToShowS :: PutText ShowSSource

Accumulates persistent lines (dropping progess lines) for return by runTestText. The accumulated lines are represented by a ShowS (String -> String) function whose first argument is the string to be appended to the accumulated report lines.

runTestText :: PutText st -> Test -> IO (Counts, st)Source

Executes a test, processing each report line according to the given reporting scheme. The reporting scheme's state is threaded through calls to the reporting scheme's function and finally returned, along with final count values.

showPath :: Path -> StringSource

Converts a test case path to a string, separating adjacent elements by the colon (':'). An element of the path is quoted (as with show) when there is potential ambiguity.

showCounts :: Counts -> StringSource

Converts test execution counts to a string.

runTestTT :: Test -> IO CountsSource

Provides the "standard" text-based test controller. Reporting is made to standard error, and progress reports are included. For possible programmatic use, the final counts are returned.

The "TT" in the name suggests "Text-based reporting to the Terminal".