DISQUS

Skydeck Blog: Unit test in OCaml with OUnit

  • Alfie Barr · 2 years ago
    Can you give examples of input files to be used with your make_suite code?
  • khigia · 1 year ago
    Alfie Barr: the files in input of make_suite are regular ocaml source code, containing functions whose name begin with "test", requiring no argument and containing any OUnit tests, like following example:
    let test_my_condition () =
    let s = "not empty string" in
    OUnit.assert_string s
  • khigia · 1 year ago
    Thanks for this code, greatly appreciated!

    I have been using some other plugin to build make_suite itself (to put make_suite in the source of my project, not as external tools).

    But then, it was difficult to add rule in ocamlbuild to first build the tool, then use it to create the executable to run the suite.

    Thus I merge both code (make_suite and your ocamlbuild plugin) to create run_test.ml ... which does make_suite + actions of ocamlbuild plugin.

    Not bad, but of course it doesn't enable to share the make_suite tools between project ... however we could share a library which ease to write the run_suite in each project.

    Anyway, main point is: thanks for code and inspiration!
  • khigia · 1 year ago
    Ooops! my previous comment is not clear ... my run_test do not run the test (no dynamic evaluation) but embed the code from myocamlbuild to search for files ... that's all!