hspec-1.8.1.1: Behavior-Driven Development for Haskell

Safe Haskell | None

Test.Hspec.Monadic

Contents

- Types
- Defining a spec
- Running a spec
- Interface to the non-monadic API
- Deprecated types and functions

Description

Deprecated: use Test.Hspec, Test.Hspec.Runner or Test.Hspec.Core instead

Synopsis

- type Spec = SpecM ()
- class Example a
- describe :: String -> Spec -> Spec
- context :: String -> Spec -> Spec
- it :: Example a => String -> a -> Spec
- pending :: Expectation
- hspec :: Spec -> IO ()
- data Summary = Summary {
  - summaryExamples :: Int
  - summaryFailures :: Int
  }
- runSpecM :: Spec -> [SpecTree]
- fromSpecList :: [SpecTree] -> Spec
- type Specs = Spec
- descriptions :: [Spec] -> Spec
- hspecB :: Spec -> IO Bool
- hspecX :: Spec -> IO ()
- hHspec :: Handle -> Spec -> IO Summary

# Types

type Spec = SpecM ()Source

class Example a Source

A type class for examples.

Instances

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

# Defining a spec

describe :: String -> Spec -> Spec Source

Combine a list of specs into a larger spec.

context :: String -> Spec -> Spec Source

An alias for `describe`.

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

Create a spec item.

A spec item consists of:

- a textual description of a desired behavior
- an example for that behavior

     describe "absolute" $ do
       it "returns a positive number when given a negative number" $
         absolute (-1) == 1

pending :: Expectation Source

Specifies a pending example.

If you want to textually specify a behavior but do not have an example yet, use this:

     describe "fancyFormatter" $ do
       it "can format text in a way that everyone likes" $
         pending

# 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.

data Summary Source

Summary of a test run.

Constructors

Summary |

Fields

summaryExamples :: Int
summaryFailures :: Int

Instances

Eq Summary |
Show Summary |
Monoid Summary |

# Interface to the non-monadic API

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.

# Deprecated types and functions

type Specs = Spec Source

descriptions :: [Spec] -> Spec Source

hspecB :: Spec -> IO Bool Source

hspecX :: Spec -> IO ()Source

hHspec :: Handle -> Spec -> IO Summary Source