package ppx_test

  1. Overview
  2. Docs

Module Ppx_test.TestSource

Sourcetype t

The test type

Test registration
Sourceval test_unit : Location.t -> Longident.t -> (unit -> unit) -> unit

Add a test of type unit -> unit. This is called when let %TEST_UNIT ppx phrase is called.

Sourceval test : Location.t -> Longident.t -> (unit -> bool) -> unit

Add a test of type unit -> bool. This is called when let %TEST ppx phrase is called.

Sourceval test_fail : Location.t -> Longident.t -> (unit -> unit) -> unit

Add a test of type unit -> unit. It must fail by raising an exception. This is called when let %TEST_FAIL ppx phrase is called.

Module opened in the test code
Sourcemodule TestTool : sig ... end
Higher level API
Sourceval collect : unit -> unit

Run tests added by test, test_unit and add. Then it prints the report to stderr and exit. The exit status is 0 if there is no error, otherwise, 1.

This is for standalone test executables: it parses command line options using arg_specs to select tests to perform. All the tests are executed by default.

For application programs with integrated test interface, use run_tests instead.

Middle level APIs
Sourcemodule Name : sig ... end

Name of tests

Sourcemodule Error : sig ... end

Test error descriptions

Sourcemodule Result : sig ... end

Test result

Sourcemodule Report : sig ... end

Report for the test run

Sourceval run_tests : bool -> Report.t

Run tests added by test, test_unit and add. It returns a report.

This is for application programs with integrated tests.

The boolean is to set the default value to perform each test or not. For test selections, applications must use arg_specs at its command line option parsing.

Sourceval arg_specs : (string * Arg.spec * string) list

Command line switches for testing options. Useful when integrating the tests into main applications instead of building independent test executables.

Lower level APIs
Sourceval add : t -> unit
Sourceval fun_ : (unit -> bool) -> t
Sourceval label : string -> t -> t
Sourceval ident : Longident.t -> t -> t
Sourceval list : t list -> t