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.
a lightweight test framework. Nice terminal UI with color for results.
Alcotestcan compare many different kinds of outputs, but requires a bit more boilerplate than
expect-test, as well as looking up different kinds of tests.
an older but still competitive unit test framework for OCaml.
Tests are done via
assert_equalstatements. A little bit of boilerplate is needed.
- QCheck: a library that allows you to create unit tests based on random input.
write simple inline pragmas within your code to generate unit tests.
QChecktests 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.
- Cucumber.ml: Behavior Driven Development using Cucumber.
State machine framework for testing imperative code.
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.
- Crowbar: Quickcheck tests + fuzzing courtesy of afl-fuzz.
- bun: Integrate fuzzing into your CI.
- Article about fuzzing with Crowbar, bun and afl-fuzz
- Monolith can also be used for fuzzing.