Test.Hspec.Core
Description
This module contains the core types, constructors, classes, instances, and utility functions common to hspec.
- data Result
- data Spec = Spec {}
- data Formatter = Formatter {
- exampleGroupStarted :: Handle -> Spec -> IO ()
- examplePassed :: Handle -> Spec -> [String] -> IO ()
- exampleFailed :: Handle -> Spec -> [String] -> IO ()
- examplePending :: Handle -> Spec -> [String] -> IO ()
- errorsFormatter :: Handle -> [String] -> IO ()
- footerFormatter :: Handle -> [Spec] -> Double -> IO ()
- describe :: String -> [IO (String, Result)] -> IO [IO Spec]
- descriptions :: [IO [IO Spec]] -> IO [IO Spec]
- safely :: Result -> IO Result
- class SpecVerifier a where
- pending :: String -> Result
- failedCount :: [Spec] -> Int
- failure :: [Spec] -> Bool
- success :: [Spec] -> Bool
- isFailure :: Result -> Bool
- quantify :: Num a => a -> String -> String
Documentation
The result of running an example.
Instances
Everything needed to specify and show a specific behavior.
Constructors
| Formatter | |
Fields
| |
Arguments
| :: String | The name of what is being described, usually a function or type. |
| -> [IO (String, Result)] | A list of behaviors and examples, created by a list of |
| -> IO [IO Spec] |
Create a set of specifications for a specific type being described. Once you know what you want specs for, use this.
describe "abs" [
it "returns a positive number given a negative number"
(abs (-1) == 1)
]
safely :: Result -> IO ResultSource
Evaluate a Result. Any exceptions (undefined, etc.) are treated as failures.
class SpecVerifier a whereSource
Anything that can be used as an example of a behavior.
Methods
Arguments
| :: String | A description of this behavior. |
| -> a | An example for this behavior. |
| -> IO (String, Result) |
Create a description and example of a behavior, a list of these
is used by describe. Once you know what you want to specify, use this.
describe "closeEnough" [
it "is true if two numbers are almost the same"
(1.001 `closeEnough` 1.002),
it "is false if two numbers are not almost the same"
(not $ 1.001 `closeEnough` 1.003)
]
Instances
| SpecVerifier Bool | |
| SpecVerifier Test | |
| SpecVerifier Result | |
| SpecVerifier (IO ()) | |
| Testable t => SpecVerifier (QuickCheckProperty t) |
Declare an example as not successful or failing but pending some other work. If you want to report on a behavior but don't have an example yet, use this.
describe "fancyFormatter" [
it "can format text in a way that everyone likes"
(pending "waiting for clarification from the designers")
]
failedCount :: [Spec] -> IntSource