hspec- Behavior Driven Development for Haskell

Safe HaskellNone




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



type Spec = SpecM ()Source

class Example a Source

A type class for examples.


data Pending Source

A pending example.

Defining a spec

describe :: String -> Spec -> SpecSource

Combine a list of specs into a larger spec.

context :: String -> Spec -> SpecSource

An alias for describe.

it :: Example v => String -> v -> SpecSource

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 :: String -> PendingSource

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" $

You can give an optional reason for why it's pending:

 describe "fancyFormatter" $ do
   it "can format text in a way that everyone likes" $
     pending "waiting for clarification from the designers"

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.

(see also hspecWith)

data Summary Source

Summary of a test run.



Interface to the non-monadic API

runSpecM :: Spec -> [SpecTree]Source

Convert a Spec to a forest of SpecTrees.

fromSpecList :: [SpecTree] -> SpecSource

Create a Spec from a forest of SpecTrees.

Deprecated types and functions