Safe Haskell | None |
---|---|
Language | Haskell2010 |
Console reporter ingredient
Synopsis
- consoleTestReporter :: Ingredient
- consoleTestReporterWithHook :: ([TestName] -> Result -> IO Result) -> Ingredient
- newtype Quiet = Quiet Bool
- newtype HideSuccesses = HideSuccesses Bool
- newtype AnsiTricks = AnsiTricks {}
- data UseColor
- useColor :: UseColor -> Bool -> Bool
- data Statistics = Statistics {
- statTotal :: !Int
- statFailures :: !Int
- computeStatistics :: StatusMap -> IO Statistics
- printStatistics :: (?colors :: Bool) => Statistics -> Time -> IO ()
- printStatisticsNoTime :: (?colors :: Bool) => Statistics -> IO ()
- data TestOutput
- = PrintTest String (IO ()) (Result -> IO ())
- | PrintHeading String (IO ()) TestOutput
- | Skip
- | Seq TestOutput TestOutput
- buildTestOutput :: (?colors :: Bool) => OptionSet -> TestTree -> TestOutput
- foldTestOutput :: Monoid b => (String -> IO () -> IO Result -> (Result -> IO ()) -> b) -> (String -> IO () -> b -> b) -> TestOutput -> StatusMap -> b
- withConsoleFormat :: (?colors :: Bool) => ConsoleFormatPrinter
Documentation
consoleTestReporter :: Ingredient #
A simple console UI
consoleTestReporterWithHook :: ([TestName] -> Result -> IO Result) -> Ingredient #
A simple console UI with a hook to postprocess results, depending on their names and external conditions (e. g., its previous outcome, stored in a file). Names are listed in reverse order: from test's own name to a name of the outermost test group.
Since: 1.4.2
Do not print test results (see README for details)
newtype HideSuccesses #
Report only failed tests
Instances
Eq HideSuccesses # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter (==) :: HideSuccesses -> HideSuccesses -> Bool # (/=) :: HideSuccesses -> HideSuccesses -> Bool # | |
Ord HideSuccesses # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter compare :: HideSuccesses -> HideSuccesses -> Ordering # (<) :: HideSuccesses -> HideSuccesses -> Bool # (<=) :: HideSuccesses -> HideSuccesses -> Bool # (>) :: HideSuccesses -> HideSuccesses -> Bool # (>=) :: HideSuccesses -> HideSuccesses -> Bool # max :: HideSuccesses -> HideSuccesses -> HideSuccesses # min :: HideSuccesses -> HideSuccesses -> HideSuccesses # | |
IsOption HideSuccesses # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter |
newtype AnsiTricks #
By default, when the option --hide-successes
is given and the output
goes to an ANSI-capable terminal, we employ some ANSI terminal tricks to
display the name of the currently running test and then erase it if it
succeeds.
These tricks sometimes fail, however—in particular, when the test names happen to be longer than the width of the terminal window. See
- https://github.com/UnkindPartition/tasty/issues/152
- https://github.com/UnkindPartition/tasty/issues/250
When that happens, this option can be used to disable the tricks. In that case, the test name will be printed only once the test fails.
Instances
Internals
The following functions and datatypes are internals that are exposed to simplify the task of rolling your own custom console reporter UI.
Output colouring
When to use color on the output
Since: 0.11.3
Instances
Eq UseColor # | |
Ord UseColor # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter | |
IsOption UseColor # | Control color output |
Defined in Test.Tasty.Ingredients.ConsoleReporter parseValue :: String -> Maybe UseColor # optionName :: Tagged UseColor String # optionHelp :: Tagged UseColor String # showDefaultValue :: UseColor -> Maybe String # |
useColor :: UseColor -> Bool -> Bool #
useColor when isTerm
decides if colors should be used,
where isTerm
indicates whether stdout
is a terminal device.
Since: 0.11.3
Test failure statistics
data Statistics #
Track the number of tests that were run and failures of a TestTree
or
sub-tree.
Since: 0.11.3
Statistics | |
|
Instances
Semigroup Statistics # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter (<>) :: Statistics -> Statistics -> Statistics # sconcat :: NonEmpty Statistics -> Statistics # stimes :: Integral b => b -> Statistics -> Statistics # | |
Monoid Statistics # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter mempty :: Statistics # mappend :: Statistics -> Statistics -> Statistics # mconcat :: [Statistics] -> Statistics # |
computeStatistics :: StatusMap -> IO Statistics #
computeStatistics
computes a summary Statistics
for
a given state of the StatusMap
.
Useful in combination with printStatistics
printStatistics :: (?colors :: Bool) => Statistics -> Time -> IO () #
printStatistics
reports test success/failure statistics and time it took
to run. The Time
results is intended to be filled in by the TestReporter
callback. The colors
ImplicitParam controls whether coloured output is
used.
Since: 0.11.3
printStatisticsNoTime :: (?colors :: Bool) => Statistics -> IO () #
printStatisticsNoTime
reports test success/failure statistics
The colors
ImplicitParam controls whether coloured output is used.
Since: 0.12
Outputting results
data TestOutput #
TestOutput
is an intermediary between output formatting and output
printing. It lets us have several different printing modes (normal; print
failures only; quiet).
Since: 0.12
PrintTest String (IO ()) (Result -> IO ()) | Name of a test, an action that prints the test name, and an action that renders the result of the action. |
PrintHeading String (IO ()) TestOutput | Name of a test group, an action that prints the heading of a test
group and the |
Skip | Inactive test (e.g. not matching the current pattern) |
Seq TestOutput TestOutput | Two sets of |
Instances
Semigroup TestOutput # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter (<>) :: TestOutput -> TestOutput -> TestOutput # sconcat :: NonEmpty TestOutput -> TestOutput # stimes :: Integral b => b -> TestOutput -> TestOutput # | |
Monoid TestOutput # | |
Defined in Test.Tasty.Ingredients.ConsoleReporter mempty :: TestOutput # mappend :: TestOutput -> TestOutput -> TestOutput # mconcat :: [TestOutput] -> TestOutput # |
buildTestOutput :: (?colors :: Bool) => OptionSet -> TestTree -> TestOutput #
Build the TestOutput
for a TestTree
and OptionSet
. The colors
ImplicitParam controls whether the output is colored.
Since: 0.11.3
:: Monoid b | |
=> (String -> IO () -> IO Result -> (Result -> IO ()) -> b) | Eliminator for test cases. The |
-> (String -> IO () -> b -> b) | Eliminator for test groups. The |
-> TestOutput | The |
-> StatusMap | The |
-> b |
Fold function for the TestOutput
tree into a Monoid
.
Since: 0.12
withConsoleFormat :: (?colors :: Bool) => ConsoleFormatPrinter #
Run action with console configured for a specific output format
This function does not apply any output formats if colors are disabled at command line or console detection.
Can be used by providers that wish to provider specific result details printing, while re-using the tasty formats and coloring logic.
Since: 1.3.1