Module Tezt

Tezt core library.

Tezt (pronounced "tezty", as in "tasty" with a "z") is a test framework for OCaml. It is well suited for writing and executing unit, integration and regression tests. It integrates well with continuous integration (CI).

Tezt provides a function (Test.register) to register tests. Tests have a title, some tags, and an implementation (a function). Titles and tags can be used on the command-line to select which tests to run. The name of the file in which the test was registered can also be used to do so. The implementation of the test is ran if the test is selected. If this implementation does not raise an exception (for instance by calling Test.fail), the test is considered to be successful. Along with modules Base, which is supposed to be opened a la Pervasives and which provides a few useful generic functions, and Check, which provides ways to perform assertions with nice error messages, the result is a framework that is suitable for unit tests.

Tests can be ran in a CI, optionally producing JUnit reports. Tezt can automatically compute a partition of the set of tests where subsets are balanced to take roughly the same amount of time to run. The intent is that each of those subset can be one CI job, resulting in automatic balanced parallelisation.

Specific features supporting integration tests include:

Specific features supporting regression tests include:

Tezt provides a flexible user interface:

To get started, register tests with Test.register, then call the main function Test.run. Tests are run from the command-line, for instance with dune runtest or dune exec. The latter gives access to a large list of command-line options to select which tests to run and how. Execute your program with --help to get the list. See also the Tezt mini-tutorial.

module Background : sig ... end

Support for running promises in the background.

module Base : sig ... end

Base primitives useful in writing tests.

module Check : sig ... end

Support for expressing assertions.

module Cli : sig ... end

Command-line interface options.

module JSON : sig ... end

JSON handling (encoding/decoding, accessors, error management, etc).

module Log : sig ... end

Functions for logging messages.

module Process : sig ... end

Managing external processes (spawning them, capturing outputs, exit codes, etc).

module Regression : sig ... end

Regression test helpers (run tests, capture output, etc).

module Runner : sig ... end

Runner specifications for processes spawned remotely using SSH.

module Temp : sig ... end

Temporary file management.

module Test : sig ... end

Base test management (registering, initializations, etc).