|
|
The prime way of testing something in OCaml is to use _inline tests_. Note that inline tests can only exist in libraries. |
|
You'll have to manually add the `inline_tests` field as well as the `ppx_inline_test` ppx. |
|
|
|
This test will succeed as long as it returns `true`. |
|
This test will succeed as long as it returns a unit `()`. |
|
Inline tests can be embedded in a lot of places, for example, modules. |
|
Best practice is to "hide" tests and test helpers in their own `test_module`. |
|
|
|
|
|
Note that unfortunately, the output of `dune runtest` is **nothing** if tests pass, so it's not always clear if tests are actually working or not... |
|
|
|
|
|
To run a single test, you will have to manually add this line into the dune file. It will run ALL the tests in the file, but you can be more acurate by adding a colon a line number to the name of the file. Not pretty, but it works. Just remember to remove it when you're done. |
|