Recommended QuickCheck implementation & other unit test tools?

Yet another beginner question.

  1. Google seems to show a number of QuickCheck and QuickCheck-like implementations for OCaml. Is there consensus on which one works best? (I’d rather not try all of them in sequence…)

  2. Similarly for unit test frameworks?


I’ve been very happy with Alcotest for unit tests and qcheck for generating data.


For unit testing, I’ve been meaning to try out --I like how minimalistic it is, feels like it strips out as much boilerplate as possible.

+1 to the QCheck recommendation, the documentation explains things nicely.


While we’re on the subject, has anyone had any success integrating ppx_expect with jbuilder?

1 Like

It may also be worth having a look at the various AFL-based generators like
@stedolan’s crowbar,
@yomimono’s ocaml-bun , …

I have yet to find a good article about or easy-to-follow example of how to set it up, but I think the technique has potential.
Maybe someone who has a better grip on this tooling can elaborate a bit.


ocaml-bun is intended for nice management of afl-fuzz/crowbar workflows, so I’d recommend looking at Crowbar first :slight_smile:

the Crowbar repository itself is lacking in documentation but has some examples from which it’s possible to do a bit of divination around how the workflow goes. I wrote a bit about using it here, and the tests it refers to are on github . Crowbar isn’t yet released and the API is in flux; some breaking changes got merged a few days ago, so if you want to try any existing tests out (including most of those in the Crowbar repository’s examples directory) you’ll want to check out commit cffd7df0ab1daa9109220c329eba871c0759db98 .

I’m interested myself in existing examples of OCaml projects with generative or property-based tests, regardless of the specific framework used.


I have used QCheck a little bit, for example:

I think it would be a shame to claim that any of these constitute particularly well-written examples of QCheck usage, but maybe there are parts that can be copy-pasted from.


No. I spent a few hours trying, but couldn’t figure it out.

@yomimono I think fpath and astring's test suites already got treatment from @stedolan but you are welcome to torture Gg's test suite (which uses it’s own property and generative testing framework I never polished to release).


+1 Another vote for the combo.

Although for QuickCheck, crowbar may be of interest. Mirage developers seem to use them.

EDIT: links.


I got it working using the setup described here (adapted from this comment).