Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines functions for declaring different test settings
Synopsis
- modifyMaxSuccess :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
- modifyMaxDiscardRatio :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
- modifyMaxSize :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
- modifyMaxShrinks :: (Int -> Int) -> TestDefM a b c -> TestDefM a b c
- modifyRunSettings :: (TestRunSettings -> TestRunSettings) -> TestDefM a b c -> TestDefM a b c
- data TestRunSettings = TestRunSettings {}
- sequential :: TestDefM a b c -> TestDefM a b c
- parallel :: TestDefM a b c -> TestDefM a b c
- withParallelism :: Parallelism -> TestDefM a b c -> TestDefM a b c
- data Parallelism
- randomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c
- doNotRandomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c
- withExecutionOrderRandomisation :: ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c
- data ExecutionOrderRandomisation
- modifyRetries :: (Word -> Word) -> TestDefM a b c -> TestDefM a b c
- withoutRetries :: TestDefM a b c -> TestDefM a b c
- withRetries :: Word -> TestDefM a b c -> TestDefM a b c
- flaky :: Word -> TestDefM a b c -> TestDefM a b c
- flakyWith :: Word -> String -> TestDefM a b c -> TestDefM a b c
- notFlaky :: TestDefM a b c -> TestDefM a b c
- potentiallyFlaky :: TestDefM a b c -> TestDefM a b c
- potentiallyFlakyWith :: String -> TestDefM a b c -> TestDefM a b c
- withFlakiness :: FlakinessMode -> TestDefM a b c -> TestDefM a b c
- data FlakinessMode
- = MayNotBeFlaky
- | MayBeFlaky !(Maybe String)
- expectPassing :: TestDefM a b c -> TestDefM a b c
- expectFailing :: TestDefM a b c -> TestDefM a b c
- withExpectationMode :: ExpectationMode -> TestDefM a b c -> TestDefM a b c
- data ExpectationMode
Declaring different test settings
modifyRunSettings :: (TestRunSettings -> TestRunSettings) -> TestDefM a b c -> TestDefM a b c Source #
data TestRunSettings Source #
Instances
Declaring parallelism
sequential :: TestDefM a b c -> TestDefM a b c Source #
Declare that all tests below must be run sequentially
parallel :: TestDefM a b c -> TestDefM a b c Source #
Declare that all tests below may be run in parallel. (This is the default.)
withParallelism :: Parallelism -> TestDefM a b c -> TestDefM a b c Source #
Annotate a test group with Parallelism
.
data Parallelism Source #
Instances
Generic Parallelism Source # | |
Defined in Test.Syd.SpecDef type Rep Parallelism :: Type -> Type # from :: Parallelism -> Rep Parallelism x # to :: Rep Parallelism x -> Parallelism # | |
Show Parallelism Source # | |
Defined in Test.Syd.SpecDef showsPrec :: Int -> Parallelism -> ShowS # show :: Parallelism -> String # showList :: [Parallelism] -> ShowS # | |
Eq Parallelism Source # | |
Defined in Test.Syd.SpecDef (==) :: Parallelism -> Parallelism -> Bool # (/=) :: Parallelism -> Parallelism -> Bool # | |
type Rep Parallelism Source # | |
Declaring randomisation order
randomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c Source #
Declare that the order of execution of all tests below may be randomised.
doNotRandomiseExecutionOrder :: TestDefM a b c -> TestDefM a b c Source #
Declare that the order of execution of all tests below must not be randomised.
withExecutionOrderRandomisation :: ExecutionOrderRandomisation -> TestDefM a b c -> TestDefM a b c Source #
Annotate a test group with ExecutionOrderRandomisation
.
data ExecutionOrderRandomisation Source #
Instances
Generic ExecutionOrderRandomisation Source # | |
Defined in Test.Syd.SpecDef type Rep ExecutionOrderRandomisation :: Type -> Type # | |
Show ExecutionOrderRandomisation Source # | |
Defined in Test.Syd.SpecDef showsPrec :: Int -> ExecutionOrderRandomisation -> ShowS # show :: ExecutionOrderRandomisation -> String # showList :: [ExecutionOrderRandomisation] -> ShowS # | |
Eq ExecutionOrderRandomisation Source # | |
Defined in Test.Syd.SpecDef | |
type Rep ExecutionOrderRandomisation Source # | |
Defined in Test.Syd.SpecDef type Rep ExecutionOrderRandomisation = D1 ('MetaData "ExecutionOrderRandomisation" "Test.Syd.SpecDef" "sydtest-0.15.0.0-BLgkBYH9Fsw9alo040A0D9" 'False) (C1 ('MetaCons "RandomiseExecutionOrder" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DoNotRandomiseExecutionOrder" 'PrefixI 'False) (U1 :: Type -> Type)) |
Modifying the number of retries
modifyRetries :: (Word -> Word) -> TestDefM a b c -> TestDefM a b c Source #
Modify the number of retries to use in flakiness diagnostics.
withoutRetries :: TestDefM a b c -> TestDefM a b c Source #
Turn off retries
withRetries :: Word -> TestDefM a b c -> TestDefM a b c Source #
Make the number of retries this constant
Declaring flakiness
flaky :: Word -> TestDefM a b c -> TestDefM a b c Source #
Mark a test suite as "potentially flaky" with a given number of retries.
This will retry any test in the given test group up to the given number of tries, and pass a test if it passes once. The test output will show which tests were flaky.
WARNING: This is only a valid approach to dealing with test flakiness if it is true that tests never pass accidentally. In other words: tests using flaky must be guaranteed to fail every time if an error is introduced in the code, it should only be added to deal with accidental failures, never accidental passes.
flakyWith :: Word -> String -> TestDefM a b c -> TestDefM a b c Source #
Like flaky
, but also shows the given message to the user whenever the test is flaky.
You could use it like this:
>>>
flakyWith 3 "Something sometimes goes wrong with the database, see issue 6346" ourTestSuite
notFlaky :: TestDefM a b c -> TestDefM a b c Source #
Mark a test suite as "must not be flaky".
This is useful to have a subgroup of a group marked as flaky
that must not be flaky afteral.
potentiallyFlaky :: TestDefM a b c -> TestDefM a b c Source #
Mark a test suite as 'potentially flaky', such that it will not fail if it is flaky but passes at least once.
potentiallyFlakyWith :: String -> TestDefM a b c -> TestDefM a b c Source #
Like potentiallyFlaky
, but with a message.
withFlakiness :: FlakinessMode -> TestDefM a b c -> TestDefM a b c Source #
Annotate a test group with FlakinessMode
.
data FlakinessMode Source #
Instances
Generic FlakinessMode Source # | |
Defined in Test.Syd.SpecDef type Rep FlakinessMode :: Type -> Type # from :: FlakinessMode -> Rep FlakinessMode x # to :: Rep FlakinessMode x -> FlakinessMode # | |
Show FlakinessMode Source # | |
Defined in Test.Syd.SpecDef showsPrec :: Int -> FlakinessMode -> ShowS # show :: FlakinessMode -> String # showList :: [FlakinessMode] -> ShowS # | |
Eq FlakinessMode Source # | |
Defined in Test.Syd.SpecDef (==) :: FlakinessMode -> FlakinessMode -> Bool # (/=) :: FlakinessMode -> FlakinessMode -> Bool # | |
type Rep FlakinessMode Source # | |
Defined in Test.Syd.SpecDef type Rep FlakinessMode = D1 ('MetaData "FlakinessMode" "Test.Syd.SpecDef" "sydtest-0.15.0.0-BLgkBYH9Fsw9alo040A0D9" 'False) (C1 ('MetaCons "MayNotBeFlaky" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MayBeFlaky" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe String)))) |
Declaring expectations
expectPassing :: TestDefM a b c -> TestDefM a b c Source #
Mark a test suite as 'should pass'
expectFailing :: TestDefM a b c -> TestDefM a b c Source #
Mark a test suite as 'should fail'
withExpectationMode :: ExpectationMode -> TestDefM a b c -> TestDefM a b c Source #
Annotate a test suite with ExpectationMode
data ExpectationMode Source #
Instances
Generic ExpectationMode Source # | |
Defined in Test.Syd.SpecDef type Rep ExpectationMode :: Type -> Type # from :: ExpectationMode -> Rep ExpectationMode x # to :: Rep ExpectationMode x -> ExpectationMode # | |
Show ExpectationMode Source # | |
Defined in Test.Syd.SpecDef showsPrec :: Int -> ExpectationMode -> ShowS # show :: ExpectationMode -> String # showList :: [ExpectationMode] -> ShowS # | |
Eq ExpectationMode Source # | |
Defined in Test.Syd.SpecDef (==) :: ExpectationMode -> ExpectationMode -> Bool # (/=) :: ExpectationMode -> ExpectationMode -> Bool # | |
type Rep ExpectationMode Source # | |