Page
Library
Module
Module type
Parameter
Class
Class type
Source
$ opam update
$ opam install testo
$ git clone https://github.com/mjambon/testo-template.git
$ cd testo-template
$ dune build
$ ./testCopy the template and adapt it as needed.
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.
Testo is a test framework for OCaml that takes inspiration from its predecessor Alcotest and from pytest. Features include:
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 testsstatus: check the status of the tests without re-running themapprove: approve test output and make it the new referenceA 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.