- data Result
- data Spec = Spec {}
- describe :: String -> [IO (String, Result)] -> IO [Spec]
- descriptions :: [IO [Spec]] -> IO [Spec]
- safely :: Result -> IO Result
- class SpecVerifier a where
- pending :: String -> Result
- documentSpecs :: [Spec] -> [String]
- documentGroup :: [String] -> [Spec] -> ([String], [String])
- documentSpec :: [String] -> Spec -> ([String], String)
- timingSummary :: Double -> String
- failedCount :: [Spec] -> Int
- successSummary :: [Spec] -> String
- pureHspec :: [Spec] -> [String]
- pureHspecB :: [Spec] -> ([String], Bool)
- hspec :: IO [Spec] -> IO ()
- hspecB :: IO [Spec] -> IO Bool
- hspecX :: IO [Spec] -> IO a
- toExitCode :: Bool -> ExitCode
- hHspec :: Handle -> IO [Spec] -> IO Bool
- quantify :: Num a => a -> String -> String
Documentation
The result of running an example.
Everything needed to specify and show a specific behavior.
:: 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 [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.
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) ]
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") ]
documentSpecs :: [Spec] -> [String]Source
Create a document of the given specs.
documentGroup :: [String] -> [Spec] -> ([String], [String])Source
Create a document of the given group of specs.
timingSummary :: Double -> StringSource
Create a summary of how long it took to run the examples.
failedCount :: [Spec] -> IntSource
successSummary :: [Spec] -> StringSource
Create a summary of how many specs exist and how many examples failed.
Create a document of the given specs. This does not track how much time it took to check the examples. If you want a description of each spec and don't need to know how long it tacks to check, use this.
hspec :: IO [Spec] -> IO ()Source
Create a document of the given specs and write it to stdout. This does track how much time it took to check the examples. Use this if you want a description of each spec and do need to know how long it tacks to check the examples or want to write to stdout.
hspecB :: IO [Spec] -> IO BoolSource
Same as hspec
except it returns a bool indicating if all examples ran without failures
hspecX :: IO [Spec] -> IO aSource
Same as hspec
except the program exits successfull if all examples ran without failures or
with an errorcode of 1 if any examples failed.
toExitCode :: Bool -> ExitCodeSource
:: Handle | A handle for the stream you want to write to. |
-> IO [Spec] | The specs you are interested in. |
-> IO Bool |
Create a document of the given specs and write it to the given handle. This does track how much time it took to check the examples. Use this if you want a description of each spec and do need to know how long it tacks to check the examples or want to write to a file or other handle.
writeReport filename specs = withFile filename WriteMode (\ h -> hHspec h specs)