Test.Hspec.Core.Runner

hspec-core-2.4.2: A Testing Framework for Haskell

Stability | provisional
Safe Haskell | None
Language | Haskell2010

Test.Hspec.Core.Runner

Contents

- Running a spec
- Types

Description

Synopsis

- hspec :: Spec -> IO ()
- hspecWith :: Config -> Spec -> IO ()
- hspecResult :: Spec -> IO Summary
- hspecWithResult :: Config -> Spec -> IO Summary
- data Summary = Summary {
  - summaryExamples :: Int
  - summaryFailures :: Int
  }
- data Config = Config {
  - configIgnoreConfigFile :: Bool
  - configDryRun :: Bool
  - configPrintCpuTime :: Bool
  - configFastFail :: Bool
  - configFailureReport :: Maybe FilePath
  - configRerun :: Bool
  - configRerunAllOnSuccess :: Bool
  - configFilterPredicate :: Maybe (Path -> Bool)
  - configSkipPredicate :: Maybe (Path -> Bool)
  - configQuickCheckSeed :: Maybe Integer
  - configQuickCheckMaxSuccess :: Maybe Int
  - configQuickCheckMaxDiscardRatio :: Maybe Int
  - configQuickCheckMaxSize :: Maybe Int
  - configSmallCheckDepth :: Int
  - configColorMode :: ColorMode
  - configDiff :: Bool
  - configFormatter :: Maybe Formatter
  - configHtmlOutput :: Bool
  - configOutputFile :: Either Handle FilePath
  - configConcurrentJobs :: Maybe Int
  }
- data ColorMode
  - = ColorAuto
  - | ColorNever
  - | ColorAlways
- type Path = ([String], String)
- defaultConfig :: Config
- configAddFilter :: (Path -> Bool) -> Config -> Config

# Running a spec

hspec :: Spec -> IO () #

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

hspecWith :: Config -> Spec -> IO () #

Run given spec with custom options. This is similar to `hspec`, but more flexible.

hspecResult :: Spec -> IO Summary #

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.

hspecWithResult :: Config -> Spec -> IO Summary #

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

Note: `hspecWithResult` 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 #

Summary of a test run.

Constructors

Summary |
Fields summaryExamples :: Int summaryFailures :: Int

Instances

Eq Summary # |
Methods (==) :: Summary -> Summary -> Bool # (/=) :: Summary -> Summary -> Bool #
Show Summary # |
Methods showsPrec :: Int -> Summary -> ShowS # show :: Summary -> String # showList :: [Summary] -> ShowS #
Monoid Summary # |
Methods mempty :: Summary # mappend :: Summary -> Summary -> Summary # mconcat :: [Summary] -> Summary #

data Config #

Constructors

Config |
Fields configIgnoreConfigFile :: Bool configDryRun :: Bool configPrintCpuTime :: Bool configFastFail :: Bool configFailureReport :: Maybe FilePath configRerun :: Bool configRerunAllOnSuccess :: 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. configSkipPredicate :: Maybe (Path -> Bool) configQuickCheckSeed :: Maybe Integer configQuickCheckMaxSuccess :: Maybe Int configQuickCheckMaxDiscardRatio :: Maybe Int configQuickCheckMaxSize :: Maybe Int configSmallCheckDepth :: Int configColorMode :: ColorMode configDiff :: Bool configFormatter :: Maybe Formatter configHtmlOutput :: Bool configOutputFile :: Either Handle FilePath configConcurrentJobs :: Maybe Int

data ColorMode #

Constructors

ColorAuto |
ColorNever |
ColorAlways |

Instances

Eq ColorMode # |
Methods (==) :: ColorMode -> ColorMode -> Bool # (/=) :: ColorMode -> ColorMode -> Bool #
Show ColorMode # |
Methods showsPrec :: Int -> ColorMode -> ShowS # show :: ColorMode -> String # showList :: [ColorMode] -> ShowS #

type Path = ([String], String) #

A `Path` represents the location of an example within the spec tree.

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

defaultConfig :: Config #

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

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