-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Behavior-Driven Development for Haskell -- -- Behavior-Driven Development for Haskell -- -- Hspec is roughly based on the Ruby library RSpec. However, Hspec is -- just a framework for running HUnit and QuickCheck tests. Compared to -- other options, it provides a much nicer syntax that makes tests very -- easy to read. -- -- The Hspec Manual is at http://hspec.github.com/. @package hspec @version 1.4.2 -- | This module contains formatters that can be used with -- hspecWith. module Test.Hspec.Formatters silent :: Formatter specdoc :: Formatter progress :: Formatter failed_examples :: Formatter data Formatter Formatter :: FormatM () -> (Int -> [String] -> String -> FormatM ()) -> FormatM () -> (Path -> FormatM ()) -> (Path -> Either SomeException String -> FormatM ()) -> (Path -> Maybe String -> FormatM ()) -> FormatM () -> FormatM () -> Formatter headerFormatter :: Formatter -> FormatM () -- | evaluated before each test group -- -- The given number indicates the position within the parent group. exampleGroupStarted :: Formatter -> Int -> [String] -> String -> FormatM () exampleGroupDone :: Formatter -> FormatM () -- | evaluated after each successful example exampleSucceeded :: Formatter -> Path -> FormatM () -- | evaluated after each failed example exampleFailed :: Formatter -> Path -> Either SomeException String -> FormatM () -- | evaluated after each pending example examplePending :: Formatter -> Path -> Maybe String -> FormatM () -- | evaluated after a test run failedFormatter :: Formatter -> FormatM () -- | evaluated after failuresFormatter footerFormatter :: Formatter -> FormatM () data FormatM a -- | Get the number of successful examples encountered so far. getSuccessCount :: FormatM Int -- | Get the number of pending examples encountered so far. getPendingCount :: FormatM Int -- | Get the number of failed examples encountered so far. getFailCount :: FormatM Int -- | Get the total number of examples encountered so far. getTotalCount :: FormatM Int data FailureRecord FailureRecord :: Path -> Either SomeException String -> FailureRecord failureRecordPath :: FailureRecord -> Path failureRecordMessage :: FailureRecord -> Either SomeException String -- | Get the list of accumulated failure messages. getFailMessages :: FormatM [FailureRecord] -- | Get the used CPU time since the test run has been started. getCPUTime :: FormatM (Maybe Double) -- | Get the passed real time since the test run has been started. getRealTime :: FormatM Double -- | Append some output to the report. write :: String -> FormatM () -- | The same as write, but adds a newline character. writeLine :: String -> FormatM () -- | Append an empty line to the report. -- -- Calling this multiple times has the same effect as calling it once. newParagraph :: FormatM () -- | Set output to color green, run given action, and finally restore the -- default color. withSuccessColor :: FormatM a -> FormatM a -- | Set output color to yellow, run given action, and finally restore the -- default color. withPendingColor :: FormatM a -> FormatM a -- | Set output color to red, run given action, and finally restore the -- default color. withFailColor :: FormatM a -> FormatM a module Test.Hspec.HUnit -- | Convert a HUnit test suite to a spec. This can be used to run existing -- HUnit tests with Hspec. fromHUnitTest :: Test -> Spec instance Example Test module Test.Hspec.Runner -- | Run given spec and write a report to stdout. Exit with -- exitFailure if at least one spec item fails. -- -- (see also hspecWith) hspec :: Spec -> IO () -- | Run given spec with custom options. This is similar to hspec, -- but more flexible. -- -- Note: hspecWith does not exit with exitFailure on -- failing spec items. If you need this, you have to check the -- Summary yourself and act accordingly. hspecWith :: Config -> Spec -> IO Summary -- | Summary of a test run. data Summary Summary :: Int -> Int -> Summary summaryExamples :: Summary -> Int summaryFailures :: Summary -> Int data Config Config :: Bool -> Bool -> Bool -> Maybe (Path -> Bool) -> Params -> ColorMode -> Formatter -> Bool -> Handle -> Config configVerbose :: Config -> Bool configPrintCpuTime :: Config -> Bool configReRun :: Config -> Bool -- | A predicate that is used to filter the spec before it is run. Only -- examples that satisfy the predicate are run. configFilterPredicate :: Config -> Maybe (Path -> Bool) configParams :: Config -> Params configColorMode :: Config -> ColorMode configFormatter :: Config -> Formatter configHtmlOutput :: Config -> Bool configHandle :: Config -> Handle data ColorMode ColorAuto :: ColorMode ColorNever :: ColorMode ColorAlway :: ColorMode -- | A tuple that represents the location of an example within a spec. -- -- It consists of a list of group descriptions and a requirement -- description. type Path = ([String], String) defaultConfig :: Config -- | Add a filter predicate to config. If there is already a filter -- predicate, then combine them with ||. configAddFilter :: (Path -> Bool) -> Config -> Config instance Eq Summary instance Show Summary instance Monoid Summary -- | This module provides access to Hspec's internals. It is less stable -- than other parts of the API. For most users Test.Hspec is more -- suitable! module Test.Hspec.Core -- | A type class for examples. class Example a evaluateExample :: Example a => Params -> a -> IO Result data Params Params :: Args -> Params paramsQuickCheckArgs :: Params -> Args -- | The result of running an example. data Result Success :: Result Pending :: (Maybe String) -> Result Fail :: String -> Result -- | A writer monad for SpecTree forests. data SpecM a -- | Convert a Spec to a forest of SpecTrees. runSpecM :: Spec -> [SpecTree] -- | Create a Spec from a forest of SpecTrees. fromSpecList :: [SpecTree] -> Spec -- | Internal representation of a spec. data SpecTree SpecGroup :: String -> [SpecTree] -> SpecTree SpecItem :: String -> (Params -> IO Result) -> SpecTree -- | The describe function combines a list of specs into a larger -- spec. describe :: String -> [SpecTree] -> SpecTree -- | Create a spec item. it :: Example a => String -> a -> SpecTree -- | Deprecated: use `SpecTree` instead type Spec = SpecTree -- | Deprecated: use `[SpecTree]` instead type Specs = [SpecTree] -- | Deprecated: use `Test.Hspec.Runner.hspecWith` instead hspecB :: [SpecTree] -> IO Bool -- | Deprecated: use `Test.Hspec.Runner.hspec` instead hspecX :: [SpecTree] -> IO () -- | Deprecated: use `Test.Hspec.Runner.hspecWith` instead hHspec :: Handle -> [SpecTree] -> IO Summary -- | Deprecated: use `Test.Hspec.Runner.hspec` instead hspec :: [SpecTree] -> IO () -- | Deprecated: use `Test.Hspec.Pending` instead type Pending = Pending -- | Deprecated: use `Test.Hspec.pending` instead pending :: String -> Pending -- | Hspec is a framework for Behavior-Driven Development (BDD) in -- Haskell. BDD is an approach to software development that combines -- Test-Driven Development, Domain-Driven Design, and Acceptance -- Test-Driven Planning. Hspec helps you do the TDD part of that -- equation, focusing on the documentation and design aspects of TDD. -- -- Hspec (and the preceding intro) are based on the Ruby library RSpec. -- Much of what applies to RSpec also applies to Hspec. Hspec ties -- together textual descriptions of behavior and examples -- for that behavior. The examples serve as test cases for the specified -- behavior. Hspec's mechanism for examples is extensible. Support for -- QuickCheck properties and HUnit tests is included in the core package. module Test.Hspec type Spec = SpecM () -- | A type class for examples. class Example a -- | A pending example. data Pending -- | Combine a list of specs into a larger spec. describe :: String -> Spec -> Spec -- | An alias for describe. context :: String -> Spec -> Spec -- | Create a spec item. -- -- A spec item consists of: -- -- -- --
--   describe "absolute" $ do
--     it "returns a positive number when given a negative number" $
--       absolute (-1) == 1
--   
it :: Example v => String -> v -> Spec -- | A pending example. -- -- 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
--   
-- -- 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"
--   
pending :: String -> Pending -- | Run given spec and write a report to stdout. Exit with -- exitFailure if at least one spec item fails. -- -- (see also hspecWith) hspec :: Spec -> IO () -- | Deprecated: use "Test.Hspec", "Test.Hspec.Runner" or -- "Test.Hspec.Core" instead module Test.Hspec.Monadic type Spec = SpecM () -- | A type class for examples. class Example a -- | A pending example. data Pending -- | Combine a list of specs into a larger spec. describe :: String -> Spec -> Spec -- | An alias for describe. context :: String -> Spec -> Spec -- | Create a spec item. -- -- A spec item consists of: -- -- -- --
--   describe "absolute" $ do
--     it "returns a positive number when given a negative number" $
--       absolute (-1) == 1
--   
it :: Example v => String -> v -> Spec -- | A pending example. -- -- 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
--   
-- -- 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"
--   
pending :: String -> Pending -- | Run given spec and write a report to stdout. Exit with -- exitFailure if at least one spec item fails. -- -- (see also hspecWith) hspec :: Spec -> IO () -- | Summary of a test run. data Summary Summary :: Int -> Int -> Summary summaryExamples :: Summary -> Int summaryFailures :: Summary -> Int -- | Convert a Spec to a forest of SpecTrees. runSpecM :: Spec -> [SpecTree] -- | Create a Spec from a forest of SpecTrees. fromSpecList :: [SpecTree] -> Spec type Specs = Spec descriptions :: [Spec] -> Spec hspecB :: Spec -> IO Bool hspecX :: Spec -> IO () hHspec :: Handle -> Spec -> IO Summary module Test.Hspec.QuickCheck property :: Testable prop => prop -> Property -- |
--   prop ".." $
--     ..
--   
-- -- is a shortcut for -- --
--   it ".." $ property $
--     ..
--   
prop :: Testable prop => String -> prop -> Spec