package testo

  1. Overview
  2. Docs
Test framework for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

testo-0.4.0.tbz
sha256=70f9be1524b57c28f73c2c84937ee9f779478e91fa359dc63642898dd131697b
sha512=332631c8a6c031f712a54ffe6f15969abd966c4771db569905c66bd574c3ead20a5ce3feb74883f0fe93b13ab99128347917165ba4dc5c2af23ffc1aa95eb7f9

Description

Testo is a test framework for OCaml providing new subcommands for capturing, checking, and approving the output of tests.

Published: 06 Mar 2026

README

Testo(caml) CircleCI badge

Quick start

$ opam update
$ opam install testo
$ git clone https://github.com/mjambon/testo-template.git
$ cd testo-template
$ dune build
$ ./test

Copy the template and adapt it as needed.

Documentation: testocaml.net

Contributing

Testo is maintained by the OCaml community for the OCaml community. If you see anything you like or dislike, let us know!

See our contribution guidelines.

Features

Testo is a test framework for OCaml that takes inspiration from its predecessor Alcotest and from pytest. Features include:

  • support for explicit XFAIL tests i.e. tests that are expected to fail, indicating that they should be fixed eventually;
  • support for test snapshots i.e. persistent storage of captured stdout, stderr, or output files;
  • reviewing and approving tests without re-running them;
  • nested test suites;
  • various ways to select tests;
  • parallel execution (using multiprocessing);
  • supports OCaml >= 4.08.

A test executable is generated from a list of tests written in OCaml. The function to interpret the command line and run things is Testo.interpret_argv. The core subcommands supported by a test executable are:

  • run: run tests
  • status: check the status of the tests without re-running them
  • approve: approve test output and make it the new reference

A test is fundamentally a name and test function of type unit -> unit. A test is considered successful if the test function returns normally and is considered failed if it raises an exception. A test is created with Testo.create which takes a variety of options in addition to the name and the test function.

For example, checking that some test result res equals an expected value of 42 is written as:

Testo.(check int) 42 res;

This raises an exception that is turned into a nice error message.

Dependencies (6)

  1. testo-util = version
  2. re >= "1.10.0"
  3. fpath
  4. cmdliner >= "1.1.0"
  5. ocaml >= "4.08.0"
  6. dune >= "3.18"

Dev Dependencies (4)

  1. utop with-dev-setup
  2. ocamlformat >= "0.28.0" & < "0.29.0" & with-dev-setup
  3. odoc >= "3.1.0" & with-doc
  4. alcotest with-test

Used by

None

Conflicts

None