| Copyright | ⓒ Anselm Schüler 2022 |
|---|---|
| License | MIT |
| Maintainer | Anselm Schüler <mail@anselmschueler.com> |
| Stability | stable |
| Portability | Portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Distribution.TestSuite.QuickCheck
Description
This module allows you to easily make Cabal tests for the detailed-0.9 interface. See the docs.
It sets sensible option declarations for the tests.
This module re-uses record names from Distribution.TestSuite and Test.QuickCheck.
It is recommended that you enable the DisambiguateRecordFields extension in GHC and/or import the module qualified.
For many basic tests, you don’t need to import Distribution.TestSuite.
To make a test, simply construct a PropertyTest and call getPropertyTest on it.
A simple sample test suite:
module Tests (tests) where import Distribution.TestSuite.QuickCheck import Test.QuickCheck tests = [getPropertyTestPropertyTest{name= "addition-is-commutative",tags= [],property= \a b -> a + b===b + a } ]
The tests you get as a result support several parameters:
| Property name | Valid values | Effect |
|---|---|---|
silent
| booleans | If true, all output is disabled.
Sets verbosity to Silent. See chatty.
Disabling Silent raises the verbosity to Chatty if it is not already higher. |
chatty
| booleans | If true, the default amount of output is emitted by QuickCheck.
Sets verbosity to Chatty. See chatty.
Note that setting this verbosity option to false does not undo setting it to
true, but lowers the verbosity by one level if it is not already lower. |
verbose
| booleans | If true, prints checked values as output.
Sets verbosity to Verbose. See verbose.
Note that setting this verbosity option to false does not undo setting it to
true, but lowers the verbosity by one level if it is not already lower. |
verboseShrinking
| booleans | If true, prints all checked and shrunk values as output.
See verboseShrinking. |
verbosity
| Silent,
Chatty,
or Verbose | Sets the verbosity to the desired level.
|
maxDiscardRatio
| positive integer | Maximum number of discarded tests per successful test before giving up.
See maxDiscardRatio. |
noShrinking
| booleans | Disables shrinking of test cases.
See noShrinking. |
shrinking | booleans | Opposite of noShrinking. |
maxShrinks
| nonnegative integer | Maximum number of shrinks before giving up or zero to disable shrinking.
See maxShrinks. |
maxSuccess
| positive integer | Maximum number of successful tests before succeeding.
See maxSuccess. |
maxSize
| positive integer | Size to use for the biggest test cases.
See maxSize. |
sizeScale
| positive integer | Scales all sizes by a number.
See mapSize. |
replay
| tuple of
QCGen and
nonnegative
integer or
empty | Replays a previous test case. Pass a string representing a tuple of
the usedSeed and usedSize values of a test case. Use empty string to
disable.
|
You can set default values by using getPropertyTestWith
You can access these values in your test by using getPropertyTestUsing.
Do both with getPropertyTestWithUsing.
Synopsis
- getPropertyTest :: Testable prop => PropertyTest prop -> Test
- getPropertyTestWith :: Testable prop => TestArgs -> PropertyTest prop -> Test
- getPropertyTestUsing :: Testable prop => PropertyTest (TestArgs -> prop) -> Test
- getPropertyTestWithUsing :: Testable prop => TestArgs -> PropertyTest (TestArgs -> prop) -> Test
- getPropertyTests :: Testable prop => [PropertyTest prop] -> [Test]
- propertyTestGroup :: Testable prop => String -> [PropertyTest prop] -> Test
- data PropertyTest prop = PropertyTest {}
- data TestArgs = TestArgs {
- verbosity :: Verbosity
- verboseShrinking :: Bool
- maxDiscardRatio :: Int
- noShrinking :: Bool
- maxShrinks :: Int
- maxSuccess :: Int
- maxSize :: Int
- sizeScale :: Int
- replay :: Maybe (QCGen, Int)
- data Verbosity
- argsToTestArgs :: Args -> TestArgs
- argsToTestArgsWith :: TestArgs -> Args -> TestArgs
- testArgsToArgs :: TestArgs -> Args
- stdTestArgs :: TestArgs
Create tests
getPropertyTest :: Testable prop => PropertyTest prop -> Test Source #
Get a Cabal Test from a PropertyTest
Arguments
| :: Testable prop | |
| => TestArgs | The arguments for the test |
| -> PropertyTest prop | |
| -> Test |
Get a Cabal Test from a PropertyTest with custom TestArgs
Arguments
| :: Testable prop | |
| => PropertyTest (TestArgs -> prop) | |
| -> Test |
Get a Cabal Test from a PropertyTest that takes the test arguments and returns a Testable value
getPropertyTestWithUsing Source #
Arguments
| :: Testable prop | |
| => TestArgs | The arguments for the test |
| -> PropertyTest (TestArgs -> prop) | |
| -> Test |
Get a Cabal Test with custom TestArgs from a PropertyTest that takes the test arguments and returns a testable value
getPropertyTests :: Testable prop => [PropertyTest prop] -> [Test] Source #
Get a list of Tests from a list of PropertyTests
propertyTestGroup :: Testable prop => String -> [PropertyTest prop] -> Test Source #
Get a named test group from a list of PropertyTests. These are assumed to be able to run in parallel. See testGroup and Group.
Argument data types
data PropertyTest prop Source #
Property test declaration with metadata
Arguments for altering property test behaviour.
These can be altered in the final Cabal Test using setOption.
Constructors
| TestArgs | |
Fields
| |
Datatype for setting the verbosity of tests
Instances
| Bounded Verbosity Source # | |
| Enum Verbosity Source # | |
Defined in Distribution.TestSuite.QuickCheck Methods succ :: Verbosity -> Verbosity # pred :: Verbosity -> Verbosity # fromEnum :: Verbosity -> Int # enumFrom :: Verbosity -> [Verbosity] # enumFromThen :: Verbosity -> Verbosity -> [Verbosity] # enumFromTo :: Verbosity -> Verbosity -> [Verbosity] # enumFromThenTo :: Verbosity -> Verbosity -> Verbosity -> [Verbosity] # | |
| Read Verbosity Source # | |
| Show Verbosity Source # | |
| Eq Verbosity Source # | |
| Ord Verbosity Source # | |
Defined in Distribution.TestSuite.QuickCheck | |
Functions for using arguments
argsToTestArgs :: Args -> TestArgs Source #
Transform a QuickCheck Args value to a TestArgs value, defaulting all missing properties
argsToTestArgs=argsToTestArgsWithstdTestArgs
testArgsToArgs :: TestArgs -> Args Source #
Recover arguments passed to quickCheck from a TestArgs
stdTestArgs :: TestArgs Source #
Default arguments for property tests