Bisect_ppx is the OCaml code coverage tool. Depend on it like any other PPX, then run your test suite. Each file gets a coverage report:
This gives a pretty decent sense of the gaps in your testing. It’s especially helpful when working with multiple contributors.
For a live example, see the report Bisect_ppx generates for itself.
Usage is pretty simple. There are instructions for ocamlfind, Ocamlbuild, OASIS, and Jbuilder. It basically consists of:
- making your source files depend on the
bisect_ppx
package, - running your test suite, and
- passing the resulting raw coverage statistics through Bisect_ppx’s report tool.
ocveralls by Julien Sagot submits Bisect_ppx reports to coveralls.io.
This announcement is prompted by the recent release of Bisect_ppx 1.3.0, which is a good opportunity to introduce the tool to Discourse
Bisect_ppx has actually been out for several years. It is in use by Lwt, ctypes, Oml, and Markup.ml, among other projects. It was originally Bisect, by Xavier Clerc.
Happy testing!