A property test, along with some configurable limits like how many times to run the test.
Modulehedgehog-1.7Haskell2010
Hedgehog.Internal.Property
- 30 types
- 1 class
- 62 values
- Packagehedgehog-1.7
- Exports93
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceProperty.hs
Property
30 declarationsThe property monad transformer allows both the generation of test inputs and the assertion of expectations.
Constructors
PropertyTunPropertyT :: TestT (GenT m) a
Instances23MonadTrans, MonadTransDistributive, MFunctor, MonadError, MonadReader, MonadState, …
MonadTrans PropertyTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTransDistributive PropertyTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMFunctor PropertyTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadError e m => MonadError e (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadReader r m => MonadReader r (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadState s m => MonadState s (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBase b m => MonadBase b (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBaseControl b m => MonadBaseControl b (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Monad (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyFunctor m => Functor (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadFail (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Applicative (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadPlus m => Alternative (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadPlus m => MonadPlus (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadIO m => MonadIO (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadCatch m => MonadCatch (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadThrow m => MonadThrow (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyPrimMonad m => PrimMonad (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadResource m => MonadResource (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadTest (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.Propertytype PrimState (PropertyT m) = PrimState mDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype StM (PropertyT m) a = StM (TestT (GenT m)) aDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype Transformer t PropertyT m = (Transformer t GenT m, Transformer t TestT (GenT m))Defined in hedgehog-1.7 · Hedgehog.Internal.Property
The name of a property.
Should be constructed using OverloadedStrings:
"apples" :: PropertyName
Constructors
Instances6Eq, Ord, Show, IsString, Semigroup, Lift
Eq PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift PropertyNameDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Configuration for a property test.
Constructors
PropertyConfigpropertyDiscardLimit :: !DiscardLimitpropertyShrinkLimit :: !ShrinkLimitpropertyShrinkRetries :: !ShrinkRetriespropertyTerminationCriteria :: !TerminationCriteriapropertySkip :: Maybe SkipIf this is Nothing, we take the Skip from the environment variable
HEDGEHOG_SKIP.
Instances4Eq, Ord, Show, Lift
Eq PropertyConfigDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd PropertyConfigDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow PropertyConfigDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift PropertyConfigDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The number of successful tests that need to be run before a property test is considered successful.
Can be constructed using numeric literals:
200 :: TestLimit
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift TestLimitDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift TestCountDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The number of discards to allow before giving up.
Can be constructed using numeric literals:
10000 :: DiscardLimit
Constructors
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift DiscardLimitDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The number of tests a property had to discard.
Constructors
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift DiscardCountDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The number of shrinks to try before giving up on shrinking.
Can be constructed using numeric literals:
1000 :: ShrinkLimit
Constructors
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ShrinkLimitDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The numbers of times a property was able to shrink after a failing test.
Constructors
Instances7Enum, Eq, Integral, Num, Ord, Real, …
Enum ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ShrinkCountDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Where to start running a property's tests.
Constructors
SkipNothingDon't skip anything.
SkipToTest TestCount DiscardCountSkip to a specific test number. If it fails, shrink as normal. If it passes, move on to the next test. Coverage checks are disabled.
We also need to count discards, since failing "after 7 tests" points at a different generated value than failing "after 7 tests and 5 discards".
SkipToShrink TestCount DiscardCount ShrinkPathSkip to a specific test number and shrink state. If it fails, stop without shrinking further. If it passes, the property will pass without running any more tests.
Due to implementation details, all intermediate shrink states - those on the direct path from the original test input to the target state - will be tested too, and their results discarded.
Instances5Eq, Ord, Show, IsString, Lift
Eq SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString SkipDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyWe use this instance to support usage like
withSkip "3:aB"It throws an error if the input is not a valid compressed Skip.
Lift SkipDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The path taken to reach a shrink state.
Constructors
Instances4Eq, Ord, Show, Lift
Eq ShrinkPathDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ShrinkPathDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ShrinkPathDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ShrinkPathDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The number of times to re-run a test during shrinking. This is useful if you are testing something which fails non-deterministically and you want to increase the change of getting a good shrink.
If you are doing parallel state machine testing, you should probably set
shrink retries to something like 10. This will mean that during
shrinking, a parallel test case requires 10 successful runs before it is
passes and we try a different shrink.
Can be constructed using numeric literals:
0 :: ShrinkRetries
Constructors
Instances8Enum, Eq, Integral, Num, Ord, Real, …
Enum ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ShrinkRetriesDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Set the number of times a property should be executed before it is considered successful.
If you have a test that does not involve any generators and thus does not
need to run repeatedly, you can use withTests 1 to define a property that
will only be checked once.
Set the number of times a property is allowed to discard before the test runner gives up.
Set the number of times a property is allowed to shrink before the test runner gives up and prints the counterexample.
Set the number of times a property will be executed for each shrink before the test runner gives up and tries a different shrink. See ShrinkRetries for more information.
Set the target that a property will skip to before it starts to run.
Creates a property with the default configuration.
Lift a test in to a property.
Because both TestT and PropertyT have MonadTest instances, this function is not often required. It can however be useful for writing functions directly in TestT and thus gaining a MonadTransControl instance at the expense of not being able to generate additional inputs using forAll.
An example where this is useful is parallel state machine testing, as executeParallel requires MonadBaseControl IO in order to be able to spawn threads in MonadTest.
Generates a random input for the test by running the provided generator.
Generates a random input for the test by running the provided generator.
The minimum amount of tests to run for a Property
Discards the current test entirely.
Compress a Skip into a hopefully-short alphanumeric string.
The bit that might be long is the ShrinkPath in SkipToShrink. For that, we encode the path components in base 26, alternating between uppercase and lowercase alphabets to distinguish list elements. Additionally when we have runs of equal components, we use the normal base 10 encoding to indicate the length.
This gives something which is hopefully quite short, but a human can roughly interpret it by eyeball.
Compress a ShrinkPath into a hopefully-short alphanumeric string.
We encode the path components in base 26, alternating between uppercase and lowercase alphabets to distinguish list elements. Additionally when we have runs of equal components, we use the normal base 10 encoding to indicate the length.
Group
3 declarationsA named collection of property tests.
Constructors
GroupgroupName :: !GroupNamegroupProperties :: ![(PropertyName, Property)]
The name of a group of properties.
Should be constructed using OverloadedStrings:
"fruit" :: GroupName
Constructors
Instances6Eq, Ord, Show, IsString, Semigroup, Lift
Eq GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift GroupNameDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The number of properties in a group.
Constructors
Instances7Enum, Eq, Integral, Num, Ord, Real, …
Enum PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIntegral PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyReal PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow PropertyCountDefined in hedgehog-1.7 · Hedgehog.Internal.Property
TestT
26 declarationsInstances14MonadTest, …
Monad m => MonadTest (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadTest (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ResourceT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (MaybeT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ExceptT x m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (IdentityT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ReaderT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (StateT s m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (StateT s m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (WriterT w m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (WriterT w m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTest m => MonadTest (ContT r m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (RWST r w s m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(MonadTest m, Monoid w) => MonadTest (RWST r w s m)Defined in hedgehog-1.7 · Hedgehog.Internal.Property
A test monad allows the assertion of expectations.
A test monad transformer allows the assertion of expectations.
Instances23MonadTrans, MonadTransControl, MonadTransDistributive, MFunctor, MonadError, MonadReader, …
MonadTrans TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTransControl TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadTransDistributive TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMFunctor TestTDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadError e m => MonadError e (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadReader r m => MonadReader r (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadState s m => MonadState s (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBase b m => MonadBase b (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBaseControl b m => MonadBaseControl b (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Monad (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyFunctor m => Functor (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadFail (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => Applicative (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadIO m => MonadIO (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadCatch m => MonadCatch (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadThrow m => MonadThrow (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyPrimMonad m => PrimMonad (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadResource m => MonadResource (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonad m => MonadTest (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.Propertytype PrimState (TestT m) = PrimState mDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype StM (TestT m) a = ComposeSt TestT m aDefined in hedgehog-1.7 · Hedgehog.Internal.Propertytype StT TestT a = (Either Failure a, Journal)Defined in hedgehog-1.7 · Hedgehog.Internal.Propertytype Transformer t TestT m = (Transformer t (WriterT Journal) m, Transformer t (ExceptT Failure) (WriterT Journal m))Defined in hedgehog-1.7 · Hedgehog.Internal.Property
Log messages which are recorded during a test run.
A record containing the details of a test run.
Constructors
JournaljournalLogs :: [Log]
The difference between some expected and actual value.
Constructors
Annotates the source code with a message that might be useful for debugging a test failure.
Annotates the source code with a value that might be useful for debugging a test failure.
Logs a message to be displayed as additional information in the footer of the failure report.
Logs a value to be displayed as additional information in the footer of the failure report.
Causes a test to fail.
Another name for pure ().
Fails the test if the condition provided is False.
Fails the test and shows a git-like diff if the comparison operation evaluates to False when applied to its arguments.
The comparison function is the second argument, which may be counter-intuitive to Haskell programmers. However, it allows operators to be written infix for easy reading:
diff y (<) 87
diff x (<=) r
This function behaves like the unix diff tool, which gives a 0 exit
code if the compared files are identical, or a 1 exit code code
otherwise. Like unix diff, if the arguments fail the comparison, a
/diff is shown.
Fails the test if the two arguments provided are not equal.
Fails the test if the two arguments provided are equal.
Fails the test if the value throws an exception when evaluated to weak head normal form (WHNF).
Fails the test if the value throws an exception when evaluated to normal form (NF).
Fails the test if the action throws an exception.
The benefit of using this over simply letting the exception bubble up is that the location of the closest evalM will be shown in the output.
Coverage
16 declarationsThe extent to which all classifiers cover a test.
When a given classification's coverage does not exceed the required minimum, the test will be failed.
Constructors
CoveragecoverageLabels :: Map LabelName (Label a)
Instances7Functor, Foldable, Traversable, Eq, Show, Semigroup, …
Functor CoverageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyFoldable CoverageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyTraversable CoverageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq a => Eq (Coverage a)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow a => Show (Coverage a)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup a => Semigroup (Coverage a)Defined in hedgehog-1.7 · Hedgehog.Internal.Property(Semigroup a, Monoid a) => Monoid (Coverage a)Defined in hedgehog-1.7 · Hedgehog.Internal.Property
The extent to which a test is covered by a classifier.
When a classifier's coverage does not exceed the required minimum, the test will be failed.
Constructors
Instances6Functor, Foldable, Traversable, Eq, Show, Semigroup
Functor LabelDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyFoldable LabelDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyTraversable LabelDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyEq a => Eq (Label a)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow a => Show (Label a)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup a => Semigroup (Label a)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyThis semigroup is right biased. The name, location and percentage from the rightmost Label will be kept. This shouldn't be a problem since the library doesn't allow setting multiple classes with the same
ClassifierName.
The name of a classifier.
Should be constructed using OverloadedStrings:
"apples" :: LabelName
Constructors
Instances6Eq, Ord, Show, IsString, Semigroup, Monoid
Eq LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyIsString LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonoid LabelNameDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Require a certain percentage of the tests to be covered by the classifier.
prop_with_coverage :: Property
prop_with_coverage =
property $ do
match <- forAll Gen.bool
cover 30 "True" $ match
cover 30 "False" $ not match
The example above requires a minimum of 30% coverage for both classifiers. If these requirements are not met, it will fail the test.
Records the proportion of tests which satisfy a given condition.
prop_with_classifier :: Property
prop_with_classifier =
property $ do
xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha
for_ xs $ \x -> do
classify "newborns" $ x == 0
classify "children" $ x > 0 && x < 13
classify "teens" $ x > 12 && x < 20
Add a label for each test run. It produces a table showing the percentage of test runs that produced each label.
All labels are covered
Instances5Eq, Ord, Show, Semigroup, Monoid
Eq CoverDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd CoverDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow CoverDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup CoverDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonoid CoverDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The total number of tests which are covered by a classifier.
Can be constructed using numeric literals:
30 :: CoverCount
Constructors
Instances6Eq, Num, Ord, Show, Semigroup, Monoid
Eq CoverCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum CoverCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd CoverCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow CoverCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertySemigroup CoverCountDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonoid CoverCountDefined in hedgehog-1.7 · Hedgehog.Internal.Property
The relative number of tests which are covered by a classifier.
Can be constructed using numeric literals:
30 :: CoverPercentage
Constructors
Instances5Eq, Fractional, Num, Ord, Show
Eq CoverPercentageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyFractional CoverPercentageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum CoverPercentageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd CoverPercentageDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow CoverPercentageDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Confidence
7 declarationsThe acceptable occurrence of false positives
Example, Confidence 10^9 would mean that you'd accept a false positive
for 1 in 10^9 tests.
Constructors
Instances5Eq, Num, Ord, Show, Lift
Eq ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyNum ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift ConfidenceDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Instances4Eq, Ord, Show, Lift
Eq TerminationCriteriaDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyOrd TerminationCriteriaDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyShow TerminationCriteriaDefined in hedgehog-1.7 · Hedgehog.Internal.PropertyLift TerminationCriteriaDefined in hedgehog-1.7 · Hedgehog.Internal.Property
Is true when the test coverage satisfies the specified Confidence contstraint for all 'Coverage CoverCount's
Is true when there exists a label that is sure to have failed according to the Confidence constraint
Make sure that the result is statistically significant in accordance to the passed Confidence
The default confidence allows one false positive in 10^9 tests
Internal
11 declarationsThese functions are exported in case you need them in a pinch, but are not part of the public API and may change at any time, even as part of a minor update.
The default configuration for a property test.
Map a config modification function over a property.
Fails with an error that shows the difference between two values.
Fails with an error which renders the type of an exception and its error message.
Fail the test with an error message, useful for building other failure combinators.
Log some information which might be relevant to a potential test failure.