View on GitHub


Documenting everything about OCaml



OCaml has many testing frameworks to choose from:

  • expect-test: a Cram framework for OCaml, enabled by PPX metaprogramming. Write some code that creates textual output, then create expectation tests that test against said output. Usage of PPX means you need to write a minimal amount of code, and the simplicity means you don’t need to look up much.
  • Alcotest: a lightweight test framework. Nice terminal UI with color for results. Alcotest can compare many different kinds of outputs, but requires a bit more boilerplate than expect-test, as well as looking up different kinds of tests.
  • OUnit: an older but still competitive unit test framework for OCaml. Tests are done via assert_equal statements. A little bit of boilerplate is needed.
  • QCheck: a library that allows you to create unit tests based on random input.
  • qtest: write simple inline pragmas within your code to generate unit tests. qtest can integrate QCheck tests to have random testing, too.
  • Kaputt: a comprehensive testing framework.
  • Pa_test: general inline testing macros.
  • TestSimple: a lightweight unit testing framework compatible with the Test Anything Protocol.
  • Behavior Driven Development using Cucumber.
  • qcstm: State machine framework for testing imperative code. Built on QCheck. Paper Video
  • Monolith: Specify the behavior of a program and perform random or fuzz testing on it automatically. Paper
  • mdx: Execute OCaml code blocks inside Markdown files. Also supports Cram tests.


Fuzz Testing definition