QuickCheck-2.8.2: Automatic testing of Haskell programs

Safe Haskell | Safe
Language | Haskell98

Test.QuickCheck.Test

Contents

- Running tests

Description

The main test loop.

Synopsis

- data Args = Args {
  - replay :: Maybe (QCGen, 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
    - numShrinkTries :: Int
    - numShrinkFinal :: Int
    - usedSeed :: QCGen
    - usedSize :: Int
    - reason :: String
    - theException :: Maybe AnException
    - labels :: [(String, Int)]
    - output :: String
    }
  - | NoExpectedFailure {
    - numTests :: Int
    - labels :: [(String, Int)]
    - output :: String
    }
  - | InsufficientCoverage {
    - 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 -> (QCGen -> Int -> Prop) -> IO Result
- doneTesting :: State -> (QCGen -> Int -> Prop) -> IO Result
- giveUp :: State -> (QCGen -> Int -> Prop) -> IO Result
- runATest :: State -> (QCGen -> Int -> Prop) -> IO Result
- summary :: State -> [(String, Int)]
- success :: State -> IO ()
- labelPercentage :: String -> State -> Int
- insufficientCoverage :: State -> Bool
- foundFailure :: State -> Result -> [Rose Result] -> IO (Int, Int, Int)
- localMin :: State -> Result -> Result -> [Rose Result] -> IO (Int, Int, Int)
- localMin' :: State -> Result -> [Rose Result] -> IO (Int, Int, Int)
- localMinFound :: State -> Result -> IO (Int, Int, Int)
- callbackPostTest :: State -> Result -> IO Result
- callbackPostFinalFailure :: State -> Result -> IO ()

# Running tests

data Args #

Args specifies arguments to the QuickCheck driver

Constructors

Args |

Fields

- replay :: Maybe (QCGen, Int)

  Should we replay a previous test? Note: saving a seed from one version of QuickCheck and replaying it in another is not supported. If you want to store a test case permanently you should save the test case itself.

- 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 # |
Methods readsPrec :: Int -> ReadS Args # readList :: ReadS [Args] # readPrec :: ReadPrec Args # readListPrec :: ReadPrec [Args] #
Show Args # |
Methods showsPrec :: Int -> Args -> ShowS # show :: Args -> String # showList :: [Args] -> ShowS #

data Result #

Result represents the test result

Constructors

Success | A successful test run

Fields

- numTests :: Int

  Number of tests performed

- labels :: [(String, Int)]

  Labels and frequencies found during all successful tests

- output :: String

  Printed output

GaveUp | Given up

Fields

- numTests :: Int

  Number of tests performed

- labels :: [(String, Int)]

  Labels and frequencies found during all successful tests

- output :: String

  Printed output

Failure | A failed test run

Fields

- numTests :: Int

  Number of tests performed

- numShrinks :: Int

  Number of successful shrinking steps performed

- numShrinkTries :: Int

  Number of unsuccessful shrinking steps performed

- numShrinkFinal :: Int

  Number of unsuccessful shrinking steps performed since last successful shrink

- usedSeed :: QCGen

  What seed was used

- usedSize :: Int

  What was the test size

- reason :: String

  Why did the property fail

- theException :: Maybe AnException

  The exception the property threw, if any

- labels :: [(String, Int)]

  Labels and frequencies found during all successful tests

- output :: String

  Printed output

NoExpectedFailure | A property that should have failed did not

Fields

- numTests :: Int

  Number of tests performed

- labels :: [(String, Int)]

  Labels and frequencies found during all successful tests

- output :: String

  Printed output

InsufficientCoverage | The tests passed but a use of `cover` had insufficient coverage

Fields

- numTests :: Int

  Number of tests performed

- labels :: [(String, Int)]

  Labels and frequencies found during all successful tests

- output :: String

  Printed output

Instances

Show Result # |
Methods showsPrec :: Int -> Result -> ShowS # show :: Result -> String # showList :: [Result] -> ShowS #

isSuccess :: Result -> Bool #

Check if the test run result was a success

stdArgs :: Args #

The default test arguments

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

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

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

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

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

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

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

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

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

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 () #

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 #

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 #

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 -> (QCGen -> Int -> Prop) -> IO Result #

doneTesting :: State -> (QCGen -> Int -> Prop) -> IO Result #

giveUp :: State -> (QCGen -> Int -> Prop) -> IO Result #

runATest :: State -> (QCGen -> Int -> Prop) -> IO Result #

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

success :: State -> IO () #

labelPercentage :: String -> State -> Int #

insufficientCoverage :: State -> Bool #

foundFailure :: State -> Result -> [Rose Result] -> IO (Int, Int, Int) #

localMin :: State -> Result -> Result -> [Rose Result] -> IO (Int, Int, Int) #

localMin' :: State -> Result -> [Rose Result] -> IO (Int, Int, Int) #

localMinFound :: State -> Result -> IO (Int, Int, Int) #

callbackPostTest :: State -> Result -> IO Result #

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