Unit testing OCaml modules with pa_ounit

230 views Asked by At

I have a simple module to test with a few inline pa_ounit tests, i've setup the directory in the oasis style and got it all to build.

For a reference I've been using: https://github.com/janestreet/textutils

How would one execute the unit-tests for the above repo? I'm assuming there's an executable .ml file to write but what goes in this, how it is it built and does it extend the tests described at the module level in any way?

I've read the docs for pa_ounit and they just make me more confused ha.

1

There are 1 answers

0
dmbaturin On BEST ANSWER

As pa_ounit readme says, run the executable that contains tests with inline-test-runner argument.

Even without pa_ounit (when using plain OUnit), the file with tests is compiled and then executed. You should probably try OUnit itself before you start using the syntax extension so you can get the feel of the system.

OASIS, a popular build automation tool, allows you to build tests and run them with "make test" easily. See https://ocaml.org/learn/tutorials/setting_up_with_oasis.html#Tests