hspec-1.3.0: Behavior Driven Development for Haskell

Safe HaskellNone

Test.Hspec.Monadic

Contents

Synopsis

Types

data Pending Source

A pending example.

Defining a spec

describe :: String -> Spec -> SpecSource

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

context :: String -> Spec -> SpecSource

An alias for describe.

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

Create a set of specifications for a specific type being described. Once you know what you want specs for, use this.

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

pending :: String -> PendingSource

A pending example.

If you want to report on a behavior but don't have an example yet, use this.

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

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

Create a document of the given spec and write it to stdout.

Exit the program with exitSuccess if all examples passed, with exitFailure otherwise.

hspecB :: Spec -> IO BoolSource

Create a document of the given spec and write it to stdout.

Return True if all examples passed, False otherwise.

hHspec :: Handle -> Spec -> IO SummarySource

Create a document of the given specs and write it to the given handle.

 writeReport filename specs = withFile filename WriteMode (\h -> hHspec h specs)

data Summary Source

Summary of a test run.

Constructors

Summary 

Interface to the non-monadic API

runSpecM :: Spec -> [Spec]Source

Convert a monadic spec into a non-monadic spec.

fromSpecList :: [Spec] -> SpecSource

Convert a non-monadic spec into a monadic spec.