Copyright | ⓒ Anselm Schüler 2022 |
---|---|
License | MIT |
Maintainer | Anselm Schüler <mail@anselmschueler.com> |
Stability | stable |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 = [getPropertyTest
PropertyTest
{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 . |
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
- 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
:: Testable prop | |
=> TestArgs | The arguments for the test |
-> PropertyTest prop | |
-> Test |
Get a Cabal Test
from a PropertyTest
with custom TestArgs
:: 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 #
:: 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 Test
s from a list of PropertyTest
s
propertyTestGroup :: Testable prop => String -> [PropertyTest prop] -> Test Source #
Get a named test group from a list of PropertyTest
s. 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
.
TestArgs | |
|
Datatype for setting the verbosity of tests
Instances
Bounded Verbosity Source # | |
Enum Verbosity Source # | |
Defined in Distribution.TestSuite.QuickCheck 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
=argsToTestArgsWith
stdTestArgs
testArgsToArgs :: TestArgs -> Args Source #
Recover arguments passed to quickCheck
from a TestArgs
stdTestArgs :: TestArgs Source #
Default arguments for property tests