| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Falsify.Driver
Description
The main falsify driver
The main entrypoint into falsify is the falsify function, which attempts
to falsify the Property' it is given.
However, most users don't need to use this module directly; it is primarily
intended for integration of falsify in test frameworks such as tasty.
For the case of tasty specifically, see the tasty-falsify package.
Synopsis
- falsify :: Options -> Property' e a -> IO (TestOutcome' e a)
- data Options = Options {
- tests :: Word
- maxShrinks :: Maybe Word
- replay :: Maybe ReplaySeed
- maxRatio :: Word
- data ReplaySeed = ReplaySeed {}
- data ExpectFailure
- data Verbose
- parseReplaySeed :: String -> Either String ReplaySeed
- type TestOutcome = TestOutcome' String
- data TestOutcome' e a
- data RenderedTestOutcome = RenderedTestOutcome {
- testPassed :: Bool
- testOutput :: String
- renderTestOutcome :: Verbose -> ExpectFailure -> TestOutcome () -> RenderedTestOutcome
- successes :: TestOutcome' e a -> [(ReplaySeed, a)]
- discarded :: TestOutcome' e a -> Word
- failure :: TestOutcome' e a -> Maybe (ReplaySeed, e)
- failure' :: TestOutcome' e a -> Maybe (ReplaySeed, NonEmpty e)
Documentation
falsify :: Options -> Property' e a -> IO (TestOutcome' e a) Source #
Run a test: attempt to falsify the given property
Options
Options for running a test
data ReplaySeed Source #
Replay seed
By default, when we falsify a property we start with a PRNG initialized using
a random seed (produced using the system entropy; this relies on
initSMGen in splitmix). When a property fails,
we will report the exact seed used, so that the user can re-run the exact
same test again, if desired.
The definition of ReplaySeed is part of falsify's public API, to make it
possible to use custom drivers.
Constructors
| ReplaySeed | |
Fields
| |
Instances
| IsString ReplaySeed Source # | |
Defined in Test.Falsify.Internal.Driver.ReplaySeed Methods fromString :: String -> ReplaySeed # | |
| Show ReplaySeed Source # | |
Defined in Test.Falsify.Internal.Driver.ReplaySeed Methods showsPrec :: Int -> ReplaySeed -> ShowS # show :: ReplaySeed -> String # showList :: [ReplaySeed] -> ShowS # | |
| Binary ReplaySeed Source # | |
Defined in Test.Falsify.Internal.Driver.ReplaySeed | |
data ExpectFailure Source #
Do we expect the property to fail?
If ExpectFailure, the test will fail if the property does not fail.
Note that if we expect failure for a property, then we can stop at the first
failed test; the number of tests to run for the property becomes a maximum
rather than a goal.
Constructors
| ExpectFailure | |
| DontExpectFailure |
Verbose output
Note that if a test fails (and we were not expecting failure) we show the logs independent of verbosity.
Constructors
| Verbose | |
| NotVerbose |
parseReplaySeed :: String -> Either String ReplaySeed Source #
Parse ReplaySeed
Returns Left an error message if parsing failed.
Results
type TestOutcome = TestOutcome' String Source #
TestOutcome specialized to String for errors
data TestOutcome' e a Source #
Result of running falsify
This is an opaque type; see renderTestOutcome and the additional accessors
provided in Test.Falsify.Driver.
data RenderedTestOutcome Source #
Test outcome as it should be shown to the user
The rendered test outcome can usually be used directly in test framework
integration. For example, the tasty integration uses
toTastyResult :: RenderedTestOutcome -> Tasty.Result
toTastyResult RenderedTestOutcome{testPassed, testOutput}
| testPassed = Tasty.testPassed testOutput
| otherwise = Tasty.testFailed testOutputConstructors
| RenderedTestOutcome | |
Fields
| |
renderTestOutcome :: Verbose -> ExpectFailure -> TestOutcome () -> RenderedTestOutcome Source #
Render test outcome
See RenderedTestOutcome for discussion.
Additional accessors
successes :: TestOutcome' e a -> [(ReplaySeed, a)] Source #
Successful test outcomes
NOTE: Normally the a parameter for a top-level property is instantiated to
unit (()), in which case it's really only the length of the list of
successes that is relevant.
discarded :: TestOutcome' e a -> Word Source #
Number of discarded test
failure :: TestOutcome' e a -> Maybe (ReplaySeed, e) Source #
Failing test, if any
Returns the error after shrinking
failure' :: TestOutcome' e a -> Maybe (ReplaySeed, NonEmpty e) Source #
Generalization of failure that returns the full shrinking history