hspec-api-2.11.16: A Testing Framework for Haskell

Stability | stable
Safe Haskell | None
Language | Haskell2010

Test.Hspec.Api.Format.V1

Contents

- Register a formatter
- Re-exports

Description

Synopsis

- type Format = Event -> IO ()
- data FormatConfig = FormatConfig {
  - formatConfigUseColor :: Bool
  - formatConfigReportProgress :: Bool
  - formatConfigOutputUnicode :: Bool
  - formatConfigUseDiff :: Bool
  - formatConfigDiffContext :: Maybe Int
  - formatConfigExternalDiff :: Maybe (String -> String -> IO ())
  - formatConfigPrettyPrint :: Bool
  - formatConfigPrettyPrintFunction :: Maybe (String -> String -> (String, String))
  - formatConfigPrintTimes :: Bool
  - formatConfigHtmlOutput :: Bool
  - formatConfigPrintCpuTime :: Bool
  - formatConfigUsedSeed :: Integer
  - formatConfigExpectedTotalCount :: Int
  }
- data Event
  - = Started
  - | GroupStarted Path
  - | GroupDone Path
  - | Progress Path Progress
  - | ItemStarted Path
  - | ItemDone Path Item
  - | Done [(Path, Item)]
- type Progress = (Int, Int)
- type Path = ([String], String)
- data Location = Location {
  - locationFile :: FilePath
  - locationLine :: Int
  - locationColumn :: Int
  }
- newtype Seconds = Seconds Double
- data Item = Item {
  - itemLocation :: Maybe Location
  - itemDuration :: Seconds
  - itemInfo :: String
  - itemResult :: Result
  }
- data Result
  - = Success
  - | Pending (Maybe Location) (Maybe String)
  - | Failure (Maybe Location) FailureReason
- data FailureReason
  - = NoReason
  - | Reason String
  - | ExpectedButGot (Maybe String) String String
  - | Error (Maybe String) SomeException
- monadic :: MonadIO m => (m () -> IO ()) -> (Event -> m ()) -> IO Format
- registerFormatter :: (String, FormatConfig -> IO Format) -> Config -> Config
- useFormatter :: (String, FormatConfig -> IO Format) -> Config -> Config
- liftFormatter :: (String, FormatConfig -> IO Format) -> (String, FormatConfig -> IO Format)
- type SpecWith a = SpecM a ()
- data Config
- modifyConfig :: (Config -> Config) -> SpecWith a

# Documentation

type Format = Event -> IO () Source #

data FormatConfig Source #

Constructors

FormatConfig |

Fields

- formatConfigUseColor :: Bool
- formatConfigReportProgress :: Bool
- formatConfigOutputUnicode :: Bool
- formatConfigUseDiff :: Bool
- formatConfigDiffContext :: Maybe Int
- formatConfigExternalDiff :: Maybe (String -> String -> IO ())
- formatConfigPrettyPrint :: Bool

  Deprecated: use `formatConfigPrettyPrintFunction` instead

- formatConfigPrettyPrintFunction :: Maybe (String -> String -> (String, String))
- formatConfigPrintTimes :: Bool
- formatConfigHtmlOutput :: Bool
- formatConfigPrintCpuTime :: Bool
- formatConfigUsedSeed :: Integer
- formatConfigExpectedTotalCount :: Int

data Event Source #

Constructors

Started |
GroupStarted Path |
GroupDone Path |
Progress Path Progress |
ItemStarted Path |
ItemDone Path Item |
Done [(Path, Item)] |

#### Instances

Instances details

Show Event Source # |
Instance details Defined in Test.Hspec.Api.Format.V1 Methods showsPrec :: Int -> Event -> ShowS Source # show :: Event -> String Source # showList :: [Event] -> ShowS Source #

type Progress = (Int, Int) Source #

`(CurrentItem, TotalItems)` tuple.

type Path = ([String], String) Source #

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.

Since: hspec-core-2.0.0

data Location Source #

`Location` is used to represent source locations.

Constructors

Location |

Fields

- locationFile :: FilePath
- locationLine :: Int
- locationColumn :: Int

#### Instances

Instances details

Read Location |
Instance details Defined in Test.Hspec.Core.Example.Location Methods readsPrec :: Int -> ReadS Location Source # readList :: ReadS [Location] Source # readPrec :: ReadPrec Location Source # readListPrec :: ReadPrec [Location] Source #
Show Location |
Instance details Defined in Test.Hspec.Core.Example.Location Methods showsPrec :: Int -> Location -> ShowS Source # show :: Location -> String Source # showList :: [Location] -> ShowS Source #
Eq Location |
Instance details Defined in Test.Hspec.Core.Example.Location Methods (==) :: Location -> Location -> Bool Source # (/=) :: Location -> Location -> Bool Source #

newtype Seconds Source #

Constructors

Seconds Double |

#### Instances

Instances details

PrintfArg Seconds |
Instance details Defined in Test.Hspec.Core.Clock Methods formatArg :: Seconds -> FieldFormatter Source # parseFormat :: Seconds -> ModifierParser Source #
Num Seconds |
Instance details Defined in Test.Hspec.Core.Clock Methods (+) :: Seconds -> Seconds -> Seconds Source # (-) :: Seconds -> Seconds -> Seconds Source # (*) :: Seconds -> Seconds -> Seconds Source # negate :: Seconds -> Seconds Source # abs :: Seconds -> Seconds Source # signum :: Seconds -> Seconds Source # fromInteger :: Integer -> Seconds Source #
Fractional Seconds |
Instance details Defined in Test.Hspec.Core.Clock Methods (/) :: Seconds -> Seconds -> Seconds Source # recip :: Seconds -> Seconds Source # fromRational :: Rational -> Seconds Source #
Show Seconds |
Instance details Defined in Test.Hspec.Core.Clock Methods showsPrec :: Int -> Seconds -> ShowS Source # show :: Seconds -> String Source # showList :: [Seconds] -> ShowS Source #
Eq Seconds |
Instance details Defined in Test.Hspec.Core.Clock Methods (==) :: Seconds -> Seconds -> Bool Source # (/=) :: Seconds -> Seconds -> Bool Source #
Ord Seconds |
Instance details Defined in Test.Hspec.Core.Clock Methods compare :: Seconds -> Seconds -> Ordering Source # (<) :: Seconds -> Seconds -> Bool Source # (<=) :: Seconds -> Seconds -> Bool Source # (>) :: Seconds -> Seconds -> Bool Source # (>=) :: Seconds -> Seconds -> Bool Source # max :: Seconds -> Seconds -> Seconds Source # min :: Seconds -> Seconds -> Seconds Source #

data Item Source #

Constructors

Item |

Fields

- itemLocation :: Maybe Location
- itemDuration :: Seconds
- itemInfo :: String
- itemResult :: Result

#### Instances

Instances details

Show Item Source # |
Instance details Defined in Test.Hspec.Api.Format.V1.Internal Methods showsPrec :: Int -> Item -> ShowS Source # show :: Item -> String Source # showList :: [Item] -> ShowS Source #

data Result Source #

Constructors

Success |
Pending (Maybe Location) (Maybe String) |
Failure (Maybe Location) FailureReason |

#### Instances

Instances details

Show Result Source # |
Instance details Defined in Test.Hspec.Api.Format.V1.Internal Methods showsPrec :: Int -> Result -> ShowS Source # show :: Result -> String Source # showList :: [Result] -> ShowS Source #

data FailureReason Source #

Constructors

NoReason |
Reason String |
ExpectedButGot (Maybe String) String String |
Error (Maybe String) SomeException |

#### Instances

Instances details

Show FailureReason |
Instance details Defined in Test.Hspec.Core.Formatters.V1.Monad Methods showsPrec :: Int -> FailureReason -> ShowS Source # show :: FailureReason -> String Source # showList :: [FailureReason] -> ShowS Source #

monadic :: MonadIO m => (m () -> IO ()) -> (Event -> m ()) -> IO Format Source #

# Register a formatter

registerFormatter :: (String, FormatConfig -> IO Format) -> Config -> Config Source #

Make a formatter available for use with `--format`.

useFormatter :: (String, FormatConfig -> IO Format) -> Config -> Config Source #

Make a formatter available for use with `--format` and use it by default.

liftFormatter :: (String, FormatConfig -> IO Format) -> (String, FormatConfig -> IO Format) Source #

Make a formatter compatible with types from Test.Hspec.Core.Format.

# Re-exports

type SpecWith a = SpecM a () Source #

A ``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.

data Config Source #

modifyConfig :: (Config -> Config) -> SpecWith a Source #

Since: hspec-core-2.10.0