QuickCheck-2.6: Automatic testing of Haskell programs

Safe Haskell | Safe-Inferred

Test.QuickCheck.Test

Contents

- Running tests

Synopsis

- data Args = Args {
  - replay :: Maybe (StdGen, Int)
  - maxSuccess :: Int
  - maxDiscardRatio :: Int
  - maxSize :: Int
  - chatty :: Bool
  }
- data Result
  - = Success {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
  - | GaveUp {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
  - | Failure {
    - numTests :: Int
    - numShrinks :: Int
    - usedSeed :: StdGen
    - usedSize :: Int
    - reason :: String
    - interrupted :: Bool
    - labels :: [(String, Int)]
    - output :: String
    }
  - | NoExpectedFailure {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
- isSuccess :: Result -> Bool
- stdArgs :: Args
- quickCheck :: Testable prop => prop -> IO ()
- quickCheckWith :: Testable prop => Args -> prop -> IO ()
- quickCheckResult :: Testable prop => prop -> IO Result
- quickCheckWithResult :: Testable prop => Args -> prop -> IO Result
- verboseCheck :: Testable prop => prop -> IO ()
- verboseCheckWith :: Testable prop => Args -> prop -> IO ()
- verboseCheckResult :: Testable prop => prop -> IO Result
- verboseCheckWithResult :: Testable prop => Args -> prop -> IO Result
- test :: State -> (StdGen -> Int -> Prop) -> IO Result
- doneTesting :: State -> (StdGen -> Int -> Prop) -> IO Result
- giveUp :: State -> (StdGen -> Int -> Prop) -> IO Result
- runATest :: State -> (StdGen -> Int -> Prop) -> IO Result
- summary :: State -> [(String, Int)]
- success :: State -> IO ()
- foundFailure :: State -> Result -> [Rose Result] -> IO Int
- localMin :: State -> Result -> [Rose Result] -> IO Int
- localMin' :: State -> Result -> [Rose Result] -> IO Int
- localMinFound :: State -> Result -> IO Int
- callbackPostTest :: State -> Result -> IO ()
- callbackPostFinalFailure :: State -> Result -> IO ()
- safely :: State -> IO () -> IO ()

# Running tests

data Args Source

Args specifies arguments to the QuickCheck driver

Constructors

Args |
Fields replay :: Maybe (StdGen, Int) should we replay a previous test? maxSuccess :: Int maximum number of successful tests before succeeding maxDiscardRatio :: Int maximum number of discarded tests per successful test before giving up maxSize :: Int size to use for the biggest test cases chatty :: Bool whether to print anything

Instances

Read Args |
Show Args |

data Result Source

Result represents the test result

Constructors

Success |
Fields numTests :: Int number of tests performed number of tests performed number of successful tests performed number of successful tests performed labels :: [(String, Int)] labels and frequencies found during all successful tests labels and frequencies found during all successful tests labels and frequencies found during all tests labels and frequencies found during all tests output :: String printed output printed output printed output printed output
GaveUp |
Fields numTests :: Int number of tests performed number of tests performed number of successful tests performed number of successful tests performed labels :: [(String, Int)] labels and frequencies found during all successful tests labels and frequencies found during all successful tests labels and frequencies found during all tests labels and frequencies found during all tests output :: String printed output printed output printed output printed output
Failure |
Fields numTests :: Int number of tests performed number of tests performed number of successful tests performed number of successful tests performed numShrinks :: Int number of successful shrinking steps performed usedSeed :: StdGen what seed was used usedSize :: Int what was the test size reason :: String what was the reason interrupted :: Bool did the user press ctrl-C? labels :: [(String, Int)] labels and frequencies found during all successful tests labels and frequencies found during all successful tests labels and frequencies found during all tests labels and frequencies found during all tests output :: String printed output printed output printed output printed output
NoExpectedFailure |
Fields numTests :: Int number of tests performed number of tests performed number of successful tests performed number of successful tests performed labels :: [(String, Int)] labels and frequencies found during all successful tests labels and frequencies found during all successful tests labels and frequencies found during all tests labels and frequencies found during all tests output :: String printed output printed output printed output printed output

Instances

Read Result |
Show Result |

isSuccess :: Result -> Bool Source

isSuccess checks if the test run result was a success

stdArgs :: Args Source

stdArgs are the default test arguments used

quickCheck :: Testable prop => prop -> IO ()Source

Tests a property and prints the results to `stdout`.

quickCheckWith :: Testable prop => Args -> prop -> IO ()Source

Tests a property, using test arguments, and prints the results to `stdout`.

quickCheckResult :: Testable prop => prop -> IO Result Source

Tests a property, produces a test result, and prints the results to `stdout`.

quickCheckWithResult :: Testable prop => Args -> prop -> IO Result Source

Tests a property, using test arguments, produces a test result, and prints the results to `stdout`.

verboseCheck :: Testable prop => prop -> IO ()Source

Tests a property and prints the results and all test cases generated to `stdout`. This is just a convenience function that means the same as `quickCheck` `.` `verbose`.

verboseCheckWith :: Testable prop => Args -> prop -> IO ()Source

Tests a property, using test arguments, and prints the results and all test cases generated to `stdout`. This is just a convenience function that combines `quickCheckWith` and `verbose`.

verboseCheckResult :: Testable prop => prop -> IO Result Source

Tests a property, produces a test result, and prints the results and all test cases generated to `stdout`. This is just a convenience function that combines `quickCheckResult` and `verbose`.

verboseCheckWithResult :: Testable prop => Args -> prop -> IO Result Source

Tests a property, using test arguments, produces a test result, and prints the results and all test cases generated to `stdout`. This is just a convenience function that combines `quickCheckWithResult` and `verbose`.

test :: State -> (StdGen -> Int -> Prop) -> IO Result Source

doneTesting :: State -> (StdGen -> Int -> Prop) -> IO Result Source

giveUp :: State -> (StdGen -> Int -> Prop) -> IO Result Source

runATest :: State -> (StdGen -> Int -> Prop) -> IO Result Source

summary :: State -> [(String, Int)]Source

success :: State -> IO ()Source

foundFailure :: State -> Result -> [Rose Result] -> IO Int Source

localMin :: State -> Result -> [Rose Result] -> IO Int Source

localMin' :: State -> Result -> [Rose Result] -> IO Int Source

localMinFound :: State -> Result -> IO Int Source

callbackPostTest :: State -> Result -> IO ()Source

callbackPostFinalFailure :: State -> Result -> IO ()Source

safely :: State -> IO () -> IO ()Source