package qcheck

  1. Overview
  2. Docs

Runners for Tests

State

val random_state : unit -> Random.State.t

Access the current random state

val verbose : unit -> bool

Is the default mode verbose or quiet?

val set_seed : int -> unit

Change the random_state by creating a new one, initialized with the given seed.

val set_verbose : bool -> unit

Change the value of verbose ()

Conversion of tests to OUnit Tests

val to_ounit_test : ?verbose:bool -> ?rand:Random.State.t -> QCheck.Test.t -> OUnit.test

to_ounit_test ~rand t wraps t into a OUnit test

  • parameter verbose

    used to print information on stdout (default: verbose())

  • parameter rand

    the random generator to use (default: random_state ())

val to_ounit_test_cell : ?verbose:bool -> ?rand:Random.State.t -> _ QCheck.Test.cell -> OUnit.test

Same as to_ounit_test but with a polymorphic test cell

val (>:::) : string -> QCheck.Test.t list -> OUnit.test

Same as OUnit.>::: but with a list of QCheck tests

val to_ounit2_test : ?rand:Random.State.t -> QCheck.Test.t -> OUnit2.test

to_ounit2_test ?rand t wraps t into a OUnit2 test

  • parameter rand

    the random generator to use (default: a static seed for reproducibility), can be overridden with "-seed" on the command-line

val to_ounit2_test_list : ?rand:Random.State.t -> QCheck.Test.t list -> OUnit2.test list

to_ounit2_test_list ?rand t like to_ounit2_test but for a list of tests

OUnit runners

val run : ?argv:string array -> OUnit.test -> int

run test runs the test, and returns an error code that is 0 if all tests passed, 1 otherwise. This is the default runner used by the comment-to-test generator.

  • parameter argv

    the command line arguments to parse parameters from (default Sys.argv)

  • raises Arg.Bad

    in case argv contains unknown arguments

  • raises Arg.Help

    in case argv contains "--help"

    This test runner displays execution in a compact way, making it good for suites that have lots of tests.

TAP-compatible test runner, in case we want to use a test harness. It prints one line per test.

Run a Suite of Tests and Get Results

val run_tests : ?verbose:bool -> ?out:Pervasives.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.

  • returns

    an error code, 0 if all tests passed, 1 otherwise.

  • parameter verbose

    if true, prints more information about test cases

val run_tests_main : ?argv:string array -> QCheck.Test.t list -> 'a

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" for activating verbose tests
  • "--seed <n>" for repeating a previous run by setting the random seed
OCaml

Innovation. Community. Security.