Safe Haskell | Safe-Infered |
---|
Test.Hspec.Formatters
Contents
Description
This module contains formatters that take a set of specs and write to a given handle. They follow a structure similar to RSpec formatters.
- silent :: Formatter
- specdoc :: Formatter
- progress :: Formatter
- failed_examples :: Formatter
- data Formatter = Formatter {
- formatterName :: String
- exampleGroupStarted :: Int -> String -> FormatM ()
- exampleSucceeded :: Int -> String -> FormatM ()
- exampleFailed :: Int -> String -> String -> FormatM ()
- examplePending :: Int -> String -> Maybe String -> FormatM ()
- failedFormatter :: FormatM ()
- footerFormatter :: FormatM ()
- data FormatM a
- getSuccessCount :: FormatM Int
- getPendingCount :: FormatM Int
- getFailCount :: FormatM Int
- getTotalCount :: FormatM Int
- getFailMessages :: FormatM [String]
- getCPUTime :: FormatM Double
- getRealTime :: FormatM Double
- write :: String -> FormatM ()
- writeLine :: String -> FormatM ()
- withSuccessColor :: FormatM a -> FormatM a
- withPendingColor :: FormatM a -> FormatM a
- withFailColor :: FormatM a -> FormatM a
Formatters
Implementing a custom Formatter
A formatter is a set of actions. Each action is evaluated when a certain situation is encountered during a test run.
Actions live in the FormatM
monad. It provides access to the runner state
and primitives for appending to the generated report.
data Formatter
Constructors
Formatter | |
Fields
|
Accessing the runner state
getSuccessCount :: FormatM Int
Get the number of successful examples encountered so far.
getPendingCount :: FormatM Int
Get the number of pending examples encountered so far.
Get the number of failed examples encountered so far.
Get the total number of examples encountered so far.
getFailMessages :: FormatM [String]
Get the list of accumulated failure messages.
Get the used CPU time since the test run has been started.
Get the passed real time since the test run has been started.
Appending to the gerenated report
Dealing with colors
withSuccessColor :: FormatM a -> FormatM a
Set output to color green, run given action, and finally restore the default color.
withPendingColor :: FormatM a -> FormatM a
Set output color to yellow, run given action, and finally restore the default color.
withFailColor :: FormatM a -> FormatM a
Set output color to red, run given action, and finally restore the default color.