make_neg to create a negative test that is expected not to satisfy the tested property
check_exn to run a single test with a simple runner.
A test fails if the property does not hold for a given input. The simple form or the rich form) offer more elaborate forms to fail a test.
Note that while check_exn is provided for convenience to discover QCheck or to run a single test in utop, to run QCheck tests in your project you probably want to opt for a more advanced runner, or convert QCheck tests to your favorite test framework:
QCheck_base_runner for a QCheck-only runner (useful if you don't have or don't need another test framework)
QCheck_alcotest to convert to Alcotest framework
QCheck_ounit to convert to OUnit framework
type'a cell
A single property test on a value of type 'a. A Test.t wraps a cell and hides its type parameter.
make_cell gen prop builds a test that checks property prop on instances of the generator gen.
parametername
the name of the test.
parametercount
number of test cases to run, counting only the test cases which satisfy preconditions.
parameterlong_factor
the factor by which to multiply count, max_gen and max_fail when running a long test (default: 1).
parameternegative
whether the test is expected not to satisfy the tested property.
parametermax_gen
maximum number of times the generation function is called in total to replace inputs that do not satisfy preconditions (should be >= count).
parametermax_fail
maximum number of failures before we stop generating inputs. This is useful if shrinking takes too much time.
parameterretries
number of times to retry the tested property while shrinking.
parameterif_assumptions_fail
the minimum fraction of tests that must satisfy the precondition for a success to be considered valid. The fraction should be between 0. and 1. A warning will be emitted otherwise if the flag is `Warning, the test will be a failure if the flag is `Fatal. (since 0.10)
parameterprint
used in Print to display generated values failing the prop
parametercollect
(* collect values by tag, useful to display distribution of generated *)
Get the expected mode of a cell: positive indicates expected to satisfy the tested property, negative indicates expected not to satisfy the tested property.
make_neg gen prop builds a test that checks property prop on instances of the generator gen. The test is considered negative, meaning that it is expected not to satisfy the tested property. This information is recorded in an underlying test cell entry and interpreted suitably by test runners. See make_cell for a description of the parameters.
Exception raised when a test raised an exception e, with the sample that triggered the exception. Test_error (name, i, e, st) means name failed on i with exception e, and st is the stacktrace (if enabled) or an empty string.
check_cell ~long ~rand test generates up to count random values of type 'a using Gen.t and the random state st. The predicate law is called on them and if it returns false or raises an exception then we have a counter-example for the law.
parameterlong
if true then multiply the number of instances to generate by the cell's long_factor.
parametercall
function called on each test case, with the result.
parameterstep
function called on each instance of the test case, with the result.