Stability | stable |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Test.Hspec
Description
Hspec is a testing framework for Haskell.
This is the library reference for Hspec. The User's Manual contains more in-depth documentation.
- type Spec = SpecWith ()
- type SpecWith a = SpecM a ()
- type family Arg e :: *
- class Example e where
- module Test.Hspec.Expectations
- it :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- specify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- describe :: String -> SpecWith a -> SpecWith a
- context :: String -> SpecWith a -> SpecWith a
- example :: Expectation -> Expectation
- parallel :: SpecWith a -> SpecWith a
- runIO :: IO r -> SpecM a r
- pending :: Expectation
- pendingWith :: String -> Expectation
- xit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- xspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- xdescribe :: String -> SpecWith a -> SpecWith a
- xcontext :: String -> SpecWith a -> SpecWith a
- type ActionWith a = a -> IO ()
- before :: IO a -> SpecWith a -> Spec
- before_ :: IO () -> SpecWith a -> SpecWith a
- beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b
- beforeAll :: IO a -> SpecWith a -> Spec
- beforeAll_ :: IO () -> SpecWith a -> SpecWith a
- after :: ActionWith a -> SpecWith a -> SpecWith a
- after_ :: IO () -> SpecWith a -> SpecWith a
- afterAll :: ActionWith a -> SpecWith a -> SpecWith a
- afterAll_ :: IO () -> SpecWith a -> SpecWith a
- around :: (ActionWith a -> IO ()) -> SpecWith a -> Spec
- around_ :: (IO () -> IO ()) -> SpecWith a -> SpecWith a
- aroundWith :: (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b
- hspec :: Spec -> IO ()
Types
Minimal complete definition
evaluateExample
Setting expectations
module Test.Hspec.Expectations
Defining a spec
example :: Expectation -> Expectation Source #
example
is a type restricted version of id
. It can be used to get better
error messages on type mismatches.
Compare e.g.
it "exposes some behavior" $ example $ do putStrLn
with
it "exposes some behavior" $ do putStrLn
Pending spec items
During a test run a pending spec item is:
- not executed
- reported as "pending"
pending :: Expectation #
pendingWith :: String -> Expectation #
Hooks
type ActionWith a = a -> IO () #
beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b #
beforeAll_ :: IO () -> SpecWith a -> SpecWith a #
after :: ActionWith a -> SpecWith a -> SpecWith a #
afterAll :: ActionWith a -> SpecWith a -> SpecWith a #
aroundWith :: (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b #