hspec-1.8.1.1: Behavior-Driven Development for Haskell

Stability | experimental
Safe Haskell | None

Test.Hspec.Core

Contents

- A type class for examples
- A writer monad for constructing specs
- Internal representation of a spec tree
- Deprecated types and functions

Description

This module provides access to Hspec's internals. It is less stable than other parts of the API. For most users Test.Hspec is more suitable!

Synopsis

- class Example a where
  - evaluateExample :: a -> Params -> (IO () -> IO ()) -> IO Result
- data Params = Params {
  - paramsQuickCheckArgs :: Args
  - paramsSmallCheckDepth :: Int
  - paramsReportProgress :: Progress -> IO ()
  }
- type Progress = (Int, Int)
- data Result
  - = Success
  - | Pending (Maybe String)
  - | Fail String
- data SpecM a
- runSpecM :: Spec -> [SpecTree]
- fromSpecList :: [SpecTree] -> Spec
- data SpecTree
  - = SpecGroup String [SpecTree]
  - | SpecItem Item
- data Item = Item {
  - itemIsParallelizable :: Bool
  - itemRequirement :: String
  - itemExample :: Params -> (IO () -> IO ()) -> IO Result
  }
- mapSpecItem :: (Item -> Item) -> Spec -> Spec
- modifyParams :: (Params -> Params) -> Spec -> Spec
- describe :: String -> [SpecTree] -> SpecTree
- it :: Example a => String -> a -> SpecTree
- type Specs = [SpecTree]
- hspecB :: [SpecTree] -> IO Bool
- hspecX :: [SpecTree] -> IO ()
- hHspec :: Handle -> [SpecTree] -> IO Summary
- hspec :: [SpecTree] -> IO ()

# A type class for examples

class Example a where Source

A type class for examples.

Methods

evaluateExample :: a -> Params -> (IO () -> IO ()) -> IO Result Source

Instances

Example Bool |
Example Test | This instance is deprecated, use `fromHUnitTest` instead!
Example Property |
Example Expectation |
Example Result |

data Params Source

Constructors

Params |

Fields

paramsQuickCheckArgs :: Args
paramsSmallCheckDepth :: Int
paramsReportProgress :: Progress -> IO ()

type Progress = (Int, Int)Source

data Result Source

The result of running an example.

Constructors

Success |
Pending (Maybe String) |
Fail String |

Instances

Eq Result |
Read Result |
Show Result |
Typeable Result |
Exception Result |
Example Result |

# A writer monad for constructing specs

data SpecM a Source

A writer monad for `SpecTree` forests.

Instances

Monad SpecM |
Functor SpecM |
Applicative SpecM |

runSpecM :: Spec -> [SpecTree]Source

Convert a `Spec` to a forest of `SpecTree`s.

fromSpecList :: [SpecTree] -> Spec Source

Create a `Spec` from a forest of `SpecTree`s.

# Internal representation of a spec tree

data SpecTree Source

Internal representation of a spec.

Constructors

SpecGroup String [SpecTree] |
SpecItem Item |

data Item Source

Constructors

Item |

Fields

itemIsParallelizable :: Bool
itemRequirement :: String
itemExample :: Params -> (IO () -> IO ()) -> IO Result

mapSpecItem :: (Item -> Item) -> Spec -> Spec Source

modifyParams :: (Params -> Params) -> Spec -> Spec Source

describe :: String -> [SpecTree] -> SpecTree Source

The `describe` function combines a list of specs into a larger spec.

it :: Example a => String -> a -> SpecTree Source

Create a spec item.

# Deprecated types and functions

type Specs = [SpecTree]Source

Deprecated: use `[SpecTree]` instead

hspecB :: [SpecTree] -> IO Bool Source

Deprecated: use `hspecWith` instead

hspecX :: [SpecTree] -> IO ()Source

Deprecated: use `hspec` instead

hHspec :: Handle -> [SpecTree] -> IO Summary Source

Deprecated: use `hspecWith` instead

hspec :: [SpecTree] -> IO ()Source

Deprecated: use `hspec` instead