Make a formatter available for use with --format.
Modulehspec-api-2.11.14Haskell2010
Test.Hspec.Api.Formatters.V2
This module contains formatters that can be used with hspecWith:
import Test.Hspec
import Test.Hspec.Api.Formatters.V1
main :: IO ()
main = hspecWith (useFormatter ("my-formatter", formatter) defaultConfig) spec
formatter :: Formatter
formatter = ...
spec :: Spec
spec = ...
- 12 types
- 36 values
- Packagehspec-api-2.11.14
- Exports48
- LanguageHaskell2010
- LicenceMIT
- SourceV2.hs
Register a formatter
3 declarationsMake a formatter available for use with --format and use it by default.
Formatters
5 declarationsImplementing a custom Formatter
8 declarationsA 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.
Constructors
FormatterformatterStarted :: FormatM ()formatterGroupStarted :: Path -> FormatM ()formatterGroupDone :: Path -> FormatM ()formatterProgress :: Path -> Progress -> FormatM ()formatterItemStarted :: Path -> FormatM ()formatterItemDone :: Path -> Item -> FormatM ()formatterDone :: FormatM ()
A Path describes the location of a spec item within a spec tree.
It consists of a list of group descriptions and a requirement description.
(CurrentItem, TotalItems) tuple.
Location is used to represent source locations.
Constructors
Constructors
Instances1Show
Show FailureReasonDefined in hspec-core-2.11.14 · Test.Hspec.Core.Formatters.V1.Monad
Instances4Monad, Functor, Applicative, MonadIO
Monad FormatMDefined in hspec-core-2.11.14 · Test.Hspec.Core.Formatters.InternalFunctor FormatMDefined in hspec-core-2.11.14 · Test.Hspec.Core.Formatters.InternalApplicative FormatMDefined in hspec-core-2.11.14 · Test.Hspec.Core.Formatters.InternalMonadIO FormatMDefined in hspec-core-2.11.14 · Test.Hspec.Core.Formatters.Internal
Accessing the runner state
Get the number of successful examples encountered so far.
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.
Get the number of spec items that will have been encountered when this run completes (if it is not terminated early).
Get the list of accumulated failure messages.
The random seed that is used for QuickCheck.
Instances6Eq, Fractional, Num, Ord, Show, PrintfArg
Eq SecondsDefined in hspec-core-2.11.14 · Test.Hspec.Core.ClockFractional SecondsDefined in hspec-core-2.11.14 · Test.Hspec.Core.ClockNum SecondsDefined in hspec-core-2.11.14 · Test.Hspec.Core.ClockOrd SecondsDefined in hspec-core-2.11.14 · Test.Hspec.Core.ClockShow SecondsDefined in hspec-core-2.11.14 · Test.Hspec.Core.ClockPrintfArg SecondsDefined in hspec-core-2.11.14 · Test.Hspec.Core.Clock
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 generated report
Append some output to the report.
The same as write, but adds a newline character.
Dealing with colors
Set output color to cyan, run given action, and finally restore the default color.
Set output color to green, run given action, and finally restore the default color.
Set output color to yellow, run given action, and finally restore the default color.
Set output color to red, run given action, and finally restore the default color.
Return the value of Test.Hspec.Core.Runner.configDiffContext.
Deprecated. use prettyPrintFunction instead
Return a function for pretty-printing if the user requested pretty diffs, Nothing otherwise.
Output given chunk in red.
Output given chunk in green.
Helpers
The function formatException converts an exception to a string.
This is different from show. The type of the exception is included, e.g.:
formatException (toException DivideByZero)"ArithException\ndivide by zero"
For IOExceptions the IOErrorType is included, as well.
Re-exports
3 declarationsA SpecWith a represents a test or group of tests that require an a
value to run.
In the common case, a Spec is a SpecWith () which requires () and
can thus be executed with hspec.
To supply an argument to SpecWith tests to turn them into Spec, use functions from Test.Hspec.Core.Hooks such as around, before, mapSubject and similar.
Values of this type are created by it, describe and similar.