hspec-1.8.1.1: Behavior-Driven Development for Haskell

Stability | provisional
Safe Haskell | None

Test.Hspec.Runner

Contents

- Running a spec
- Types
- Internals

Description

Synopsis

- hspec :: Spec -> IO ()
- hspecResult :: Spec -> IO Summary
- hspecWith :: Config -> Spec -> IO Summary
- data Summary = Summary {
  - summaryExamples :: Int
  - summaryFailures :: Int
  }
- data Config = Config {
  - configDryRun :: Bool
  - configPrintCpuTime :: Bool
  - configFastFail :: Bool
  - configFilterPredicate :: Maybe (Path -> Bool)
  - configQuickCheckArgs :: Args
  - configSmallCheckDepth :: Int
  - configColorMode :: ColorMode
  - configFormatter :: Formatter
  - configHtmlOutput :: Bool
  - configHandle :: Either Handle FilePath
  }
- data ColorMode
  - = ColorAuto
  - | ColorNever
  - | ColorAlways
- type Path = ([String], String)
- defaultConfig :: Config
- configAddFilter :: (Path -> Bool) -> Config -> Config
- hspecWithFormatter :: IsFormatter a => a -> Spec -> IO ()

# Running a spec

hspec :: Spec -> IO ()Source

Run given spec and write a report to `stdout`. Exit with `exitFailure` if at least one spec item fails.

hspecResult :: Spec -> IO Summary Source

Run given spec and returns a summary of the test run.

Note: `hspecResult` does not exit with `exitFailure` on failing spec items. If you need this, you have to check the `Summary` yourself and act accordingly.

hspecWith :: Config -> Spec -> IO Summary Source

Run given spec with custom options and returns a summary of the test run.

Note: `hspecWith` does not exit with `exitFailure` on failing spec items. If you need this, you have to check the `Summary` yourself and act accordingly.

# Types

data Summary Source

Summary of a test run.

Constructors

Summary |

Fields

summaryExamples :: Int
summaryFailures :: Int

Instances

Eq Summary |
Show Summary |
Monoid Summary |

data Config Source

Constructors

Config |

Fields

configDryRun :: Bool
configPrintCpuTime :: Bool
configFastFail :: Bool
configFilterPredicate :: Maybe (Path -> Bool)

  A predicate that is used to filter the spec before it is run. Only examples that satisfy the predicate are run.

configQuickCheckArgs :: Args
configSmallCheckDepth :: Int
configColorMode :: ColorMode
configFormatter :: Formatter
configHtmlOutput :: Bool
configHandle :: Either Handle FilePath

data ColorMode Source

Constructors

ColorAuto |
ColorNever |
ColorAlways |

Instances

Eq ColorMode |
Show ColorMode |

type Path = ([String], String)Source

A tuple that represents the location of an example within a spec.

It consists of a list of group descriptions and a requirement description.

defaultConfig :: Config Source

configAddFilter :: (Path -> Bool) -> Config -> Config Source

Add a filter predicate to config. If there is already a filter predicate, then combine them with `||`.

# Internals

hspecWithFormatter :: IsFormatter a => a -> Spec -> IO ()Source

This function is used by `hspec-discover`. It is not part of the public API and may change at any time.