Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A lightweight and colourful test framework
branch: master
Failed to load latest commit information.
examples Add a simple example
lib Bump version
CHANGES Update changes
Makefile Bump version number More README tweaks
_oasis Bump version
_tags Bump version number
configure Bump version to 0.2.0 Bump version number
opam Add opam file Bump version


Alcotest is a lightweight and colourful test framework, based on OUnit.

Alcotest exposes a much more restricted interface than OUnit, as you can only pass to a tree of callbacks of depth 2, and the callbacks are unit -> unit functions that you can build using the usual OUnit.assert_* functions or any other means (including Quickcheck-like test generators).

This limitation enables Alcotest to provide a quiet and colorful output where only faulty runs are fully displayed at the end of the run (with the full logs ready to inspect), with a simple (yet expressive) query language to select the tests to run.


A simple example:

(* Build with `ocamlbuild -pkg alcotest simple.byte` *)

(* A module with functions to test *)
module To_test = struct
  let capit letter = Char.uppercase letter
  let plus int_list = List.fold_left (fun a b -> a + b) 0 int_list

(* The tests *)
let capit () =
  OUnit.assert_equal 'A' (To_test.capit 'a')

let plus () =
  OUnit.assert_equal 7 ( [1;1;2;3])

let test_set = [
  "Capitalize" , `Quick, capit;
  "Add entries", `Slow , plus ;

(* Run it *)
let () = "My first test" [
    "test_set", test_set;

The result is a self-contained binary which displays the test results. Use ./simple.byte --help to see the runtime options.

$ ./simple.byte
test_set  0   Capitalize.                                                   [OK]
test_set  1   Add entries.                                                  [OK]
Test Successful in 0.001s. 2 tests run.

See the examples folder for more examples.

Something went wrong with that request. Please try again.