hspec-2.5.8: A Testing Framework for Haskell

Stabilityunstable
Safe HaskellNone
LanguageHaskell2010

Test.Hspec.Core

Contents

Description

Deprecated: use Test.Hspec.Core.Spec instead

Synopsis

Documentation

pendingWith :: HasCallStack -> String -> Expectation #

pendingWith is similar to pending, but it takes an additional string argument that can be used to specify the reason for why the spec item is pending.

pending :: HasCallStack -> Expectation #

pending can be used to mark a spec item as pending.

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

sequential :: SpecWith a -> SpecWith a #

sequential marks all spec items of the given spec to be evaluated sequentially.

parallel :: SpecWith a -> SpecWith a #

parallel marks all spec items of the given spec to be safe for parallel evaluation.

xspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #

xspecify is an alias for xit.

xit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #

Changing it to xit marks the corresponding spec item as pending.

This can be used to temporarily disable a spec item.

specify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #

specify is an alias for it.

xcontext :: HasCallStack => String -> SpecWith a -> SpecWith a #

xcontext is an alias for xdescribe.

xdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a #

Changing describe to xdescribe marks all spec items of the corresponding subtree as pending.

This can be used to temporarily disable spec items.

context :: HasCallStack => String -> SpecWith a -> SpecWith a #

context is an alias for describe.

mapSpecItem_ :: (Item a -> Item a) -> SpecWith a -> SpecWith a #

mapSpecItem :: (ActionWith a -> ActionWith b) -> (Item a -> Item b) -> SpecWith a -> SpecWith b #

runIO :: IO r -> SpecM a r #

Run an IO action while constructing the spec tree.

SpecM is a monad to construct a spec tree, without executing any spec items. runIO allows you to run IO actions during this construction phase. The IO action is always run when the spec tree is constructed (e.g. even when --dry-run is specified). If you do not need the result of the IO action to construct the spec tree, beforeAll may be more suitable for your use case.

fromSpecList :: [SpecTree a] -> SpecWith a #

Create a Spec from a forest of SpecTrees.

runSpecM :: SpecWith a -> IO [SpecTree a] #

Convert a Spec to a forest of SpecTrees.

type Spec = SpecWith () #

type SpecWith a = SpecM a () #

newtype SpecM a r #

A writer monad for SpecTree forests

Constructors

SpecM (WriterT [SpecTree a] IO r) 
Instances
Monad (SpecM a) 
Instance details

Defined in Test.Hspec.Core.Spec.Monad

Methods

(>>=) :: SpecM a a0 -> (a0 -> SpecM a b) -> SpecM a b #

(>>) :: SpecM a a0 -> SpecM a b -> SpecM a b #

return :: a0 -> SpecM a a0 #

fail :: String -> SpecM a a0 #

Functor (SpecM a) 
Instance details

Defined in Test.Hspec.Core.Spec.Monad

Methods

fmap :: (a0 -> b) -> SpecM a a0 -> SpecM a b #

(<$) :: a0 -> SpecM a b -> SpecM a a0 #

Applicative (SpecM a) 
Instance details

Defined in Test.Hspec.Core.Spec.Monad

Methods

pure :: a0 -> SpecM a a0 #

(<*>) :: SpecM a (a0 -> b) -> SpecM a a0 -> SpecM a b #

liftA2 :: (a0 -> b -> c) -> SpecM a a0 -> SpecM a b -> SpecM a c #

(*>) :: SpecM a a0 -> SpecM a b -> SpecM a b #

(<*) :: SpecM a a0 -> SpecM a b -> SpecM a a0 #

specItem :: (HasCallStack, Example a) => String -> a -> SpecTree (Arg a) #

The specItem function creates a spec item.

specGroup :: HasCallStack => String -> [SpecTree a] -> SpecTree a #

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

data Tree c a #

Internal tree data structure

Constructors

Node String [Tree c a] 
NodeWithCleanup c [Tree c a] 
Leaf a 
Instances
Functor (Tree c) 
Instance details

Defined in Test.Hspec.Core.Tree

Methods

fmap :: (a -> b) -> Tree c a -> Tree c b #

(<$) :: a -> Tree c b -> Tree c a #

Foldable (Tree c) 
Instance details

Defined in Test.Hspec.Core.Tree

Methods

fold :: Monoid m => Tree c m -> m #

foldMap :: Monoid m => (a -> m) -> Tree c a -> m #

foldr :: (a -> b -> b) -> b -> Tree c a -> b #

foldr' :: (a -> b -> b) -> b -> Tree c a -> b #

foldl :: (b -> a -> b) -> b -> Tree c a -> b #

foldl' :: (b -> a -> b) -> b -> Tree c a -> b #

foldr1 :: (a -> a -> a) -> Tree c a -> a #

foldl1 :: (a -> a -> a) -> Tree c a -> a #

toList :: Tree c a -> [a] #

null :: Tree c a -> Bool #

length :: Tree c a -> Int #

elem :: Eq a => a -> Tree c a -> Bool #

maximum :: Ord a => Tree c a -> a #

minimum :: Ord a => Tree c a -> a #

sum :: Num a => Tree c a -> a #

product :: Num a => Tree c a -> a #

Traversable (Tree c) 
Instance details

Defined in Test.Hspec.Core.Tree

Methods

traverse :: Applicative f => (a -> f b) -> Tree c a -> f (Tree c b) #

sequenceA :: Applicative f => Tree c (f a) -> f (Tree c a) #

mapM :: Monad m => (a -> m b) -> Tree c a -> m (Tree c b) #

sequence :: Monad m => Tree c (m a) -> m (Tree c a) #

type SpecTree a = Tree (ActionWith a) (Item a) #

A tree is used to represent a spec internally. The tree is parametrize over the type of cleanup actions and the type of the actual spec items.

data Item a #

Item is used to represent spec items internally. A spec item consists of:

  • a textual description of a desired behavior
  • an example for that behavior
  • additional meta information

Everything that is an instance of the Example type class can be used as an example, including QuickCheck properties, Hspec expectations and HUnit assertions.

Constructors

Item 

Fields

class Example e where #

A type class for examples

Minimal complete definition

evaluateExample

Associated Types

type Arg e :: * #

Methods

evaluateExample :: e -> Params -> (ActionWith (Arg e) -> IO ()) -> ProgressCallback -> IO Result #

Instances
Example Bool 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg Bool :: * #

Example Property 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg Property :: * #

Example Result 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg Result :: * #

Example Expectation 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg Expectation :: * #

Example (a -> Result) 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg (a -> Result) :: * #

Methods

evaluateExample :: (a -> Result) -> Params -> (ActionWith (Arg (a -> Result)) -> IO ()) -> ProgressCallback -> IO Result #

Example (a -> Bool) 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg (a -> Bool) :: * #

Methods

evaluateExample :: (a -> Bool) -> Params -> (ActionWith (Arg (a -> Bool)) -> IO ()) -> ProgressCallback -> IO Result #

Example (a -> Expectation) 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg (a -> Expectation) :: * #

Methods

evaluateExample :: (a -> Expectation) -> Params -> (ActionWith (Arg (a -> Expectation)) -> IO ()) -> ProgressCallback -> IO Result #

Example (a -> Property) 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg (a -> Property) :: * #

Methods

evaluateExample :: (a -> Property) -> Params -> (ActionWith (Arg (a -> Property)) -> IO ()) -> ProgressCallback -> IO Result #

data Params #

Instances
Show Params 
Instance details

Defined in Test.Hspec.Core.Example

type Progress = (Int, Int) #

type ActionWith a = a -> IO () #

An IO action that expects an argument of type a

data Result #

The result of running an example

Constructors

Result 
Instances
Show Result 
Instance details

Defined in Test.Hspec.Core.Example

Example Result 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg Result :: * #

Example (a -> Result) 
Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg (a -> Result) :: * #

Methods

evaluateExample :: (a -> Result) -> Params -> (ActionWith (Arg (a -> Result)) -> IO ()) -> ProgressCallback -> IO Result #

type Arg Result 
Instance details

Defined in Test.Hspec.Core.Example

type Arg Result = ()
type Arg (a -> Result) 
Instance details

Defined in Test.Hspec.Core.Example

type Arg (a -> Result) = a

data Location #

Location is used to represent source locations.

Deprecated functions

it :: Example a => String -> a -> SpecTree (Arg a) Source #