-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell Test Framework -- -- The Haskell Test Framework (HTF for short) lets you define unit -- tests (http://hunit.sourceforge.net), QuickCheck properties -- (http://www.cs.chalmers.se/~rjmh/QuickCheck/), and black box -- tests in an easy and convenient way. HTF uses a custom preprocessor -- that collects test definitions automatically. Furthermore, the -- preprocessor allows HTF to report failing test cases with exact file -- name and line number information. Additionally, HTF tries to produce -- highly readable output for failing tests: for example, it colors and -- pretty prints expected and actual results and provides a diff between -- the two values. -- -- The documentation of the Test.Framework.Tutorial module -- provides a tutorial for HTF. There is also a slightly out-dated blog -- article -- (http://factisresearch.blogspot.de/2011/10/new-version-of-htf-with-diffs-colors.html) -- demonstrating HTF's coloring, pretty-printing and diff functionality. -- -- HEADS UP, backwards incomatibility with prior versions: -- -- In version 0.10.0.0, the following changes could break code compiled -- against version 0.9.*: -- --
-- {"test": {"flatName": "Main:nonEmpty",
-- "location": {"file": "Tutorial.hs", "line": 17},
-- "path": ["Main","nonEmpty"],
-- "sort": "unit-test"},
-- "type":"test-start"}
--
--
--
-- {"result": "pass",
-- "message":"",
-- "test":{"flatName": "Main:nonEmpty",
-- "location": {"file": "Tutorial.hs", "line": 17},
-- "path": ["Main","nonEmpty"],
-- "sort": "unit-test"},
-- "wallTime": 0, // in milliseconds
-- "type": "test-end",
-- "location":null}
--
--
--
-- {"failures": 0,
-- "passed": 4,
-- "pending": 0,
-- "wallTime": 39, // in milliseconds
-- "errors": 0,
-- "type":"test-results"}
--
--
--
-- {"tests": [{"flatName":"Main:nonEmpty","location":{"file":"Tutorial.hs","line":17},"path":["Main","nonEmpty"],"sort":"unit-test"},
-- {"flatName":"Main:empty","location":{"file":"Tutorial.hs","line":19},"path":["Main","empty"],"sort":"unit-test"},
-- {"flatName":"Main:reverse","location":{"file":"Tutorial.hs","line":22},"path":["Main","reverse"],"sort":"quickcheck-property"},
-- {"flatName":"Main:reverseReplay","location":{"file":"Tutorial.hs","line":24},"path":["Main","reverseReplay"],"sort":"quickcheck-property"}],
-- "type":"test-list"}
--
--
-- For an exact specification, please have a look at the code of this
-- module.
module Test.Framework.JsonOutput
data TestStartEventObj
data TestEndEventObj
data TestListObj
data TestObj
data TestResultsObj
mkTestStartEventObj :: FlatTest -> String -> TestStartEventObj
mkTestEndEventObj :: FlatTestResult -> String -> TestEndEventObj
mkTestListObj :: [(FlatTest, String)] -> TestListObj
mkTestResultsObj :: Milliseconds -> Int -> Int -> Int -> Int -> TestResultsObj
decodeObj :: HTFJsonObj a => a -> ByteString
class ToJSON a => HTFJsonObj a
instance ToJSON Location
instance ToJSON TestSort
instance ToJSON TestPath
instance ToJSON TestObj
instance HTFJsonObj TestResultsObj
instance ToJSON TestResultsObj
instance HTFJsonObj TestListObj
instance ToJSON TestListObj
instance ToJSON TestResult
instance HTFJsonObj TestEndEventObj
instance ToJSON TestEndEventObj
instance HTFJsonObj TestStartEventObj
instance ToJSON TestStartEventObj
-- | This module defines functions for notifying all test reporters
-- registered about particular events in the lifecycle of a test run.
--
-- Further, it defines the standard test reporters for HTF's various
-- output formats.
module Test.Framework.TestReporter
-- | Invokes tr_reportAllTests on all test reporters registered.
reportAllTests :: ReportAllTests
-- | Invokes tr_reportGlobalStart on all test reporters registered.
reportGlobalStart :: ReportGlobalStart
-- | Invokes tr_reportTestStart on all test reporters registered.
reportTestStart :: ReportTestStart
-- | Invokes tr_reportTestResult on all test reporters registered.
reportTestResult :: ReportTestResult
-- | Invokes tr_reportGlobalResults on all test reporters
-- registered.
reportGlobalResults :: ReportGlobalResults
-- | The default test reporters for HTF.
defaultTestReporters :: Bool -> Bool -> [TestReporter]
instance Eq ReportLevel
instance Ord ReportLevel
-- | This module defines the commandline options of the test driver
-- provided by HTF.
module Test.Framework.CmdlineOptions
-- | Commandline options for running tests.
data CmdlineOptions
CmdlineOptions :: Bool -> TestFilter -> Bool -> [String] -> Bool -> Maybe Bool -> Maybe FilePath -> Bool -> Bool -> CmdlineOptions
-- | Be quiet or not.
opts_quiet :: CmdlineOptions -> Bool
-- | Run only tests matching this filter.
opts_filter :: CmdlineOptions -> TestFilter
-- | If True, display a help message and exit.
opts_help :: CmdlineOptions -> Bool
-- | Regular expressions matching test names which should not run. ,
-- opts_threads :: Maybe Int -- ^ Use Just i for parallel
-- execution with i threads, Nothing for sequential
-- execution (currently unused).
opts_negated :: CmdlineOptions -> [String]
-- | Format output for machines (JSON format) or humans. See
-- JsonOutput for a definition of the JSON format.
opts_machineOutput :: CmdlineOptions -> Bool
-- | Use Just b to enable/disable use of colors, Nothing
-- infers the use of colors.
opts_useColors :: CmdlineOptions -> Maybe Bool
-- | The output file, defaults to stdout
opts_outputFile :: CmdlineOptions -> Maybe FilePath
-- | If True, lists all tests available and exits.
opts_listTests :: CmdlineOptions -> Bool
-- | If True, each message is sent to a new ouput file (derived by
-- appending an index to opts_outputFile).
opts_split :: CmdlineOptions -> Bool
-- | The default CmdlineOptions.
defaultCmdlineOptions :: CmdlineOptions
-- | Parse commandline arguments into CmdlineOptions. Here's a
-- synopsis of the format of the commandline arguments:
--
-- -- USAGE: COMMAND [OPTION ...] PATTERN ... -- -- where PATTERN is a posix regular expression matching -- the names of the tests to run. -- -- -q --quiet only display errors -- -n PATTERN --not=PATTERN tests to exclude -- -l --list list all matching tests -- -o FILE --output-file=FILE name of output file -- --json output results in machine-readable JSON format -- --split splits results in separate files to avoid file locking (requires -o/--output-file) -- --colors=BOOL use colors or not -- -h --help display this message --parseTestArgs :: [String] -> Either String CmdlineOptions -- | The string displayed for the --help option. helpString :: String -- | Turn the CmdlineOptions into a TestConfig. testConfigFromCmdlineOptions :: CmdlineOptions -> IO TestConfig -- | This module defines function for running a set of tests. Furthermore, -- it provides functionality for organzing tests into a hierarchical -- structure. This functionality is mainly used internally in the code -- generated by the hftpp pre-processor. module Test.Framework.TestManager -- | Runs something testable by parsing the commandline arguments as test -- options (using parseTestArgs). Exits with the exit code -- returned by runTestWithArgs. This function is the main entry -- point for running tests. htfMain :: TestableHTF t => t -> IO () -- | Run something testable using the defaultCmdlineOptions. runTest :: TestableHTF t => t -> IO ExitCode -- | Run something testable using the defaultCmdlineOptions. runTest' :: TestableHTF t => t -> IO (IO (), ExitCode) -- | Run something testable, parse the CmdlineOptions from the given -- commandline arguments. Does not print the overall test results but -- returns an IO action for doing so. runTestWithArgs :: TestableHTF t => [String] -> t -> IO ExitCode -- | Run something testable, parse the CmdlineOptions from the given -- commandline arguments. runTestWithArgs' :: TestableHTF t => [String] -> t -> IO (IO (), ExitCode) -- | Runs something testable with the given CmdlineOptions. See -- runTestWithConfig for a specification of the ExitCode -- result. runTestWithOptions :: TestableHTF t => CmdlineOptions -> t -> IO ExitCode -- | Runs something testable with the given CmdlineOptions. Does not -- print the overall test results but returns an IO action for -- doing so. See runTestWithConfig for a specification of the -- ExitCode result. runTestWithOptions' :: TestableHTF t => CmdlineOptions -> t -> IO (IO (), ExitCode) -- | Runs something testable with the given TestConfig. The result -- is ExitSuccess if all tests were executed successfully, -- ExitFailure otherwise. In the latter case, an error code of -- 1 indicates that failures but no errors occurred, otherwise -- the error code 2 is used. -- -- A test is successful if the test terminates and no assertion -- fails. A test is said to fail if an assertion fails but no -- other error occur. runTestWithConfig :: TestableHTF t => TestConfig -> t -> IO ExitCode -- | Runs something testable with the given TestConfig. Does not -- print the overall test results but returns an IO action for -- doing so. See runTestWithConfig for a specification of the -- ExitCode result. runTestWithConfig' :: TestableHTF t => TestConfig -> t -> IO (IO (), ExitCode) -- | A type class for things that can be run as tests. Mainly used -- internally. class TestableHTF t -- | Construct a test where the given Assertion checks a quick check -- property. Mainly used internally by the htfpp preprocessor. makeQuickCheckTest :: TestID -> Location -> Assertion -> Test -- | Construct a unit test from the given IO action. Mainly used -- internally by the htfpp preprocessor. makeUnitTest :: TestID -> Location -> IO a -> Test -- | Construct a black box test from the given Assertion. Mainly -- used internally. makeBlackBoxTest :: TestID -> Assertion -> Test -- | Create a named TestSuite from a list of Test values. makeTestSuite :: TestID -> [Test] -> TestSuite -- | Create an unnamed TestSuite from a list of Test values. makeAnonTestSuite :: [Test] -> TestSuite -- | Extend a TestSuite with a list of Test values addToTestSuite :: TestSuite -> [Test] -> TestSuite -- | Turn a TestSuite into a proper Test. testSuiteAsTest :: TestSuite -> Test instance TestableHTF (IO a) instance TestableHTF t => TestableHTF [t] instance TestableHTF TestSuite instance TestableHTF Test -- | A black box test in the terminology of the HTF consists of a -- driver program that is run in various input files. For each input -- file, the HTF checks that the driver program exits with the correct -- exit code and that it produces the expected output. The samples -- directory of the HTF source tree shows an example for a black box -- test, see https://github.com/skogsbaer/HTF/tree/master/sample. -- -- NOTE: If you use black box tests, you have to compile your -- program with the -threaded option. Otherwise, your program -- just blocks indefinitely! module Test.Framework.BlackBoxTest -- | Use a value of this datatype to customize various aspects of your -- black box tests. data BBTArgs BBTArgs :: String -> String -> String -> String -> Bool -> Diff -> Diff -> BBTArgs -- | File extension for the file used as stdin. bbtArgs_stdinSuffix :: BBTArgs -> String -- | File extension for the file specifying expected output on stdout. bbtArgs_stdoutSuffix :: BBTArgs -> String -- | File extension for the file specifying expected output on stderr. bbtArgs_stderrSuffix :: BBTArgs -> String -- | Name of a file defining various arguments for executing the tests -- contained in a subdirectory of the test hierarchy. If a directory -- contains a such-named file, the arguments apply to all testfiles -- directly contained in this directory. See the documentation of -- blackBoxTests for a specification of the argument file format. bbtArgs_dynArgsName :: BBTArgs -> String -- | Ge verbose or not. bbtArgs_verbose :: BBTArgs -> Bool -- | Diff program for comparing output on stdout with the expected value. bbtArgs_stdoutDiff :: BBTArgs -> Diff -- | Diff program for comparing output on stderr with the expected value. bbtArgs_stderrDiff :: BBTArgs -> Diff -- | Sensible default values for BBTArgs: -- --
-- defaultBBTArgs = BBTArgs { bbtArgs_stdinSuffix = ".in"
-- , bbtArgs_stdoutSuffix = ".out"
-- , bbtArgs_stderrSuffix = ".err"
-- , bbtArgs_dynArgsName = BBTArgs
-- , bbtArgs_stdoutDiff = defaultDiff
-- , bbtArgs_stderrDiff = defaultDiff
-- , bbtArgs_verbose = False }
--
defaultBBTArgs :: BBTArgs
-- | Collects all black box tests with the given file extension stored in a
-- specific directory. For example, the invocation
--
-- -- blackBoxTests "bbt-dir" "dist/build/sample/sample" ".num" defaultBBTArgs ---- -- returns a list of Test values, one Test for each -- .num file found in bbt-dir and its subdirectories. -- (The samples directory of the HTF source tree contains the example -- shown here, see -- https://github.com/skogsbaer/HTF/tree/master/sample.) -- -- Suppose that one of the .num files is -- bbt-dir/should-pass/x.num. Running the corresponding -- Test invokes dist/build/sample/sample (the program -- under test) with bbt-dir/should-pass/x.num as input file. If -- bbt-dir/should-pass/x.num existed, its content would be used -- as stdin. The tests succeeds if the exit code of the program is zero -- and the output on stdout and stderr matches the contents of -- bbt-dir/should-pass/x.out and -- bbt-dir/should-pass/x.err, respectively. -- -- The directory bbt-dir/should-fail contains the file -- BBTArgs. If this file exists, then its content specifies -- various arguments for the test run. The file defines the arguments -- separated by newlines. Supported arguments: -- --
-- {-# OPTIONS_GHC -F -pgmF htfpp #-}
--
--
-- at the top of your source file (see the Tutorial).
module Test.Framework.HUnitWrapper
assertBool_ :: Location -> Bool -> Assertion
-- | Fail if the Bool value is False. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertBool_ and
-- assertBoolVerbose_ directly, use the macros
-- assertBool and assertBoolVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertBoolVerbose_ :: Location -> String -> Bool -> Assertion
assertEqual_ :: (Eq a, Show a) => Location -> a -> a -> Assertion
-- | Fail if the two values of type a are not equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Show but not of Pretty. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertEqual_ and assertEqualVerbose_ directly, use
-- the macros assertEqual and assertEqualVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertEqualVerbose_ :: (Eq a, Show a) => Location -> String -> a -> a -> Assertion
assertEqualPretty_ :: (Eq a, Pretty a) => Location -> a -> a -> Assertion
-- | Fail if the two values of type a are not equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Pretty. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertEqualPretty_
-- and assertEqualPrettyVerbose_ directly, use the macros
-- assertEqualPretty and assertEqualPrettyVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertEqualPrettyVerbose_ :: (Eq a, Pretty a) => Location -> String -> a -> a -> Assertion
assertEqualNoShow_ :: Eq a => Location -> a -> a -> Assertion
-- | Fail if the two values of type a are not equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is neither an instance of Show nor Pretty. Be
-- aware that in this case the generated error message might not be very
-- helpful. The String parameter in the Verbose variant
-- can be used to provide extra information about the error. Do not use
-- assertEqualNoShow_ and assertEqualNoShowVerbose_
-- directly, use the macros assertEqualNoShow and
-- assertEqualNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertEqualNoShowVerbose_ :: Eq a => Location -> String -> a -> a -> Assertion
assertNotEqual_ :: (Eq a, Show a) => Location -> a -> a -> Assertion
-- | Fail if the two values of type a are equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Show but not of Pretty. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertNotEqual_ and assertNotEqualVerbose_ directly,
-- use the macros assertNotEqual and
-- assertNotEqualVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertNotEqualVerbose_ :: (Eq a, Show a) => Location -> String -> a -> a -> Assertion
assertNotEqualPretty_ :: (Eq a, Pretty a) => Location -> a -> a -> Assertion
-- | Fail if the two values of type a are equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is an instance of Pretty. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertNotEqualPretty_
-- and assertNotEqualPrettyVerbose_ directly, use the macros
-- assertNotEqualPretty and assertNotEqualPrettyVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertNotEqualPrettyVerbose_ :: (Eq a, Pretty a) => Location -> String -> a -> a -> Assertion
assertNotEqualNoShow_ :: Eq a => Location -> a -> a -> Assertion
-- | Fail if the two values of type a are equal. The first
-- parameter denotes the expected value. Use these two functions of
-- a is neither an instance of Show nor Pretty. Be
-- aware that in this case the generated error message might not be very
-- helpful. The String parameter in the Verbose variant
-- can be used to provide extra information about the error. Do not use
-- assertNotEqualNoShow_ and
-- assertNotEqualNoShowVerbose_ directly, use the macros
-- assertNotEqualNoShow and assertNotEqualNoShowVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertNotEqualNoShowVerbose_ :: Eq a => Location -> String -> a -> a -> Assertion
assertListsEqualAsSets_ :: (Eq a, Show a) => Location -> [a] -> [a] -> Assertion
-- | Fail if the two given lists are not equal when considered as sets. The
-- first list parameter denotes the expected value. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use
-- assertListsEqualAsSets_ and
-- assertListsEqualAsSetsVerbose_ directly, use the macros
-- assertListsEqualAsSets and
-- assertListsEqualAsSetsVerbose instead. These macros, provided
-- by the htfpp preprocessor, insert the Location
-- parameter automatically.
assertListsEqualAsSetsVerbose_ :: (Eq a, Show a) => Location -> String -> [a] -> [a] -> Assertion
assertNotEmpty_ :: Location -> [a] -> Assertion
-- | Fail if the given list is empty. The String parameter in the
-- Verbose variant can be used to provide extra information
-- about the error. Do not use assertNotEmpty_ and
-- assertNotEmptyVerbose_ directly, use the macros
-- assertNotEmpty and assertNotEmptyVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertNotEmptyVerbose_ :: Location -> String -> [a] -> Assertion
assertEmpty_ :: Location -> [a] -> Assertion
-- | Fail if the given list is a non-empty list. The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertEmpty_ and
-- assertEmptyVerbose_ directly, use the macros
-- assertEmpty and assertEmptyVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertEmptyVerbose_ :: Location -> String -> [a] -> Assertion
assertThrows_ :: Exception e => Location -> a -> (e -> Bool) -> Assertion
-- | Fail if evaluating the expression of type a does not throw an
-- exception satisfying the given predicate (e -> Bool). The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertThrows_ and assertThrowsVerbose_ directly, use
-- the macros assertThrows and assertThrowsVerbose
-- instead. These macros, provided by the htfpp preprocessor,
-- insert the Location parameter automatically.
assertThrowsVerbose_ :: Exception e => Location -> String -> a -> (e -> Bool) -> Assertion
assertThrowsSome_ :: Location -> a -> Assertion
-- | Fail if evaluating the expression of type a does not throw an
-- exception. The String parameter in the Verbose variant
-- can be used to provide extra information about the error. Do not use
-- assertThrowsSome_ and assertThrowsSomeVerbose_
-- directly, use the macros assertThrowsSome and
-- assertThrowsSomeVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsSomeVerbose_ :: Location -> String -> a -> Assertion
assertThrowsIO_ :: Exception e => Location -> IO a -> (e -> Bool) -> Assertion
-- | Fail if executing the IO action does not throw an exception
-- satisfying the given predicate (e -> Bool). The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertThrowsIO_ and assertThrowsIOVerbose_ directly,
-- use the macros assertThrowsIO and
-- assertThrowsIOVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsIOVerbose_ :: Exception e => Location -> String -> IO a -> (e -> Bool) -> Assertion
assertThrowsSomeIO_ :: Location -> IO a -> Assertion
-- | Fail if executing the IO action does not throw an exception.
-- The String parameter in the Verbose variant can be
-- used to provide extra information about the error. Do not use
-- assertThrowsSomeIO_ and assertThrowsSomeIOVerbose_
-- directly, use the macros assertThrowsSomeIO and
-- assertThrowsSomeIOVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertThrowsSomeIOVerbose_ :: Location -> String -> IO a -> Assertion
assertLeft_ :: Show b => Location -> Either a b -> IO a
-- | Fail if the given Either a b value is a Right. Use
-- this function if b is an instance of Show The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertLeft_ and assertLeftVerbose_ directly, use the
-- macros assertLeft and assertLeftVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertLeftVerbose_ :: Show b => Location -> String -> Either a b -> IO a
assertLeftNoShow_ :: Location -> Either a b -> IO a
-- | Fail if the given Either a b value is a Right. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertLeftNoShow_ and assertLeftNoShowVerbose_
-- directly, use the macros assertLeftNoShow and
-- assertLeftNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertLeftNoShowVerbose_ :: Location -> String -> Either a b -> IO a
assertRight_ :: Show a => Location -> Either a b -> IO b
-- | Fail if the given Either a b value is a Left. Use this
-- function if a is an instance of Show The String
-- parameter in the Verbose variant can be used to provide extra
-- information about the error. Do not use assertRight_ and
-- assertRightVerbose_ directly, use the macros
-- assertRight and assertRightVerbose instead. These
-- macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertRightVerbose_ :: Show a => Location -> String -> Either a b -> IO b
assertRightNoShow_ :: Location -> Either a b -> IO b
-- | Fail if the given Either a b value is a Left. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertRightNoShow_ and assertRightNoShowVerbose_
-- directly, use the macros assertRightNoShow and
-- assertRightNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertRightNoShowVerbose_ :: Location -> String -> Either a b -> IO b
assertJust_ :: Location -> Maybe a -> IO a
-- | Fail is the given Maybe a value is a Nothing. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertJust_ and assertJustVerbose_ directly, use the
-- macros assertJust and assertJustVerbose instead.
-- These macros, provided by the htfpp preprocessor, insert the
-- Location parameter automatically.
assertJustVerbose_ :: Location -> String -> Maybe a -> IO a
assertNothing_ :: Show a => Location -> Maybe a -> Assertion
-- | Fail is the given Maybe a value is a Just. Use this
-- function if a is an instance of Show. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertNothing_ and assertNothingVerbose_ directly,
-- use the macros assertNothing and
-- assertNothingVerbose instead. These macros, provided by the
-- htfpp preprocessor, insert the Location parameter
-- automatically.
assertNothingVerbose_ :: Show a => Location -> String -> Maybe a -> Assertion
assertNothingNoShow_ :: Location -> Maybe a -> Assertion
-- | Fail is the given Maybe a value is a Just. The
-- String parameter in the Verbose variant can be used to
-- provide extra information about the error. Do not use
-- assertNothingNoShow_ and assertNothingNoShowVerbose_
-- directly, use the macros assertNothingNoShow and
-- assertNothingNoShowVerbose instead. These macros, provided by
-- the htfpp preprocessor, insert the Location parameter
-- automatically.
assertNothingNoShowVerbose_ :: Location -> String -> Maybe a -> Assertion
-- | Fail with the given reason, supplying the error location and the error
-- message.
assertFailure_ :: Location -> String -> IO a
unitTestPending :: String -> IO a
-- | Use unitTestPending' msg test to mark the given test as
-- pending without removing it from the test suite and without deleting
-- or commenting out the test code.
unitTestPending' :: String -> IO a -> IO a
-- | Sub assertions are a poor man's way of abstracting over assertions
-- while still propagating location information. Say you want to abstract
-- over the assertion that an Int is positive. You would write
--
-- -- assertIsPositive :: Int -> Assertion -- assertIsPositive n = assertBool (n > 0) ---- -- You can now use assertIsPositive i for some integer -- i from your unit tests, but if you call it directly you will -- lose location information: if assertIsPositive i fails you -- will only get the location where assertIsPositive is defined -- but not from where it has been called. -- -- To recover the location information you simply use subAssert -- (assertIsPositive i). In this case, if i is not -- positive, you will get the location of the caller. -- -- Note: Don't use subAssert_ directly but use the preprocessor -- macro subAssert. subAssert_ :: MonadBaseControl IO m => Location -> m () -> m () -- | Same as subAssert_ but with an additional error message. subAssertVerbose_ :: MonadBaseControl IO m => Location -> String -> m () -> m () -- | Top-level module that re-exports functionality from sub-modules. -- Modules that only define unit tests and quickcheck properties -- typically only need to import this module. Your test driver should -- additionally import TestManager and, if needed, -- BlackBoxTest. module Test.Framework -- | Construct a unit test from the given IO action. Mainly used -- internally by the htfpp preprocessor. makeUnitTest :: TestID -> Location -> IO a -> Test -- | Construct a test where the given Assertion checks a quick check -- property. Mainly used internally by the htfpp preprocessor. makeQuickCheckTest :: TestID -> Location -> Assertion -> Test -- | Create a named TestSuite from a list of Test values. makeTestSuite :: TestID -> [Test] -> TestSuite -- | Abstract type for test suites and their results. data TestSuite -- | Runs something testable by parsing the commandline arguments as test -- options (using parseTestArgs). Exits with the exit code -- returned by runTestWithArgs. This function is the main entry -- point for running tests. htfMain :: TestableHTF t => t -> IO () -- | Create a new location. makeLoc :: String -> Int -> Location -- | This module provides a short tutorial on how to use the HTF. It -- assumes that you are using GHC for compiling your Haskell code. (It is -- possible to use the HTF with other Haskell environments, only the -- steps taken to invoke the custom preprocessor of the HTF may differ in -- this case.) -- -- We start with a simple example. Then we show how to use HTF to easily -- collect test definitions from multiple modules and discuss -- backwards-compatibility for projects already using HUnit. -- Finally, we give a brief cookbook-like summary on how to setup your -- tests with HTF. module Test.Framework.Tutorial