package qcheck-core
Install
Dune Dependency
Authors
Maintainers
Sources
md5=7782c8cfce30a5fb766d933e99129ee7
sha512=e1007b4a3be338406d855efcf8d13ac4961963a6c77b794ab83973950e21c777cb66ab6020a0a714f96866597bc8bf7a76a84243e5062dab5b41978e78422e0b
doc/qcheck-core.runner/QCheck_base_runner/index.html
Module QCheck_base_runner
Source
Runners for Tests
Once you built some tests using QCheck.Test.make
, you need to run the tests. This module contains several runners, which are designed to run every test and report the result.
By default, you can use run_tests
in a test program as follows:
let testsuite = [
Test.make ...;
Test.make ...;
]
let () =
let errcode = QCheck_runners.run_tests ~verbose:true testsuite in
exit errcode
which will run the tests, and exit the program. The error code will be 0 if all tests pass, 1 otherwise.
run_tests_main
can be used as a shortcut for that, also featuring command-line parsing (using Arg
) to activate verbose mode and others.
State
Access the current random state
Is the default mode verbose or quiet?
Is the default mode to run long tests or nor?
Change the random_state
by creating a new one, initialized with the given seed.
Change the value of verbose ()
Change the value of long_tests ()
Get the minimum time to wait between printing messages.
Set the minimum tiem between messages.
Run a Suite of Tests and Get Results
val run_tests :
?colors:bool ->
?verbose:bool ->
?long:bool ->
?out:out_channel ->
?rand:Random.State.t ->
QCheck.Test.t list ->
int
Run a suite of tests, and print its results. This is an heritage from the "qcheck" library.
Can be used as the main function of a test file. Exits with a non-0 code if the tests fail. It refers to run_tests
for actually running tests after CLI options have been parsed.
The available options are:
- "--verbose" (or "-v") for activating verbose tests
- "--seed <n>" (or "-s <n>") for repeating a previous run by setting the random seed
- "--long" for running the long versions of the tests
Below is an example of the output of the run_tests
and run_tests_main
function:
random seed: 438308050 generated error; fail; pass / total - time -- test name [✓] (1000) 0 ; 0 ; 1000 / 1000 -- 0.5s -- list_rev_is_involutive [✗] ( 1) 0 ; 1 ; 0 / 10 -- 0.0s -- should_fail_sort_id [✗] ( 1) 1 ; 0 ; 0 / 10 -- 0.0s -- should_error_raise_exn [✓] (1000) 0 ; 0 ; 1000 / 1000 -- 0.0s -- collect_results --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (11 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (62 shrink steps): 0 exception QCheck_runner_test.Error Raised at file "example/QCheck_runner_test.ml", line 20, characters 20-25 Called from file "src/QCheck.ml", line 839, characters 13-33 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 207 cases 3: 190 cases 2: 219 cases 1: 196 cases 0: 188 cases ================================================================================ failure (1 tests failed, 1 tests errored, ran 4 tests)