2

I'm playing around with oUnit2 and I'm wondering: is there any usage for the test_ctxt parameter, as here:

let test1 test_ctxt = assert_equal "x" (Foo.unity "x");;

Is seems superfluous to me. Is there any way to omit it while defining tests as variables?

marmistrz
  • 5,974
  • 10
  • 42
  • 94

1 Answers1

1

A value of type test_ctxt is accepted as an optional parameter in assert_command and assert_equal functions, that are main basic blocks for building tests. The test context contains, in particular, a references to loggers, that allows to run tests in parallel. Using your example a correct invocation would be:

 let test1 ctxt = assert_equal ~ctxt "x" (Foo.unit "x)
ivg
  • 34,431
  • 2
  • 35
  • 63
  • Could you add a real-life example of using those loggers that allow me to run tests in parallel? (an example how I could use ctxt inside assert_equal, after passing it) – marmistrz Oct 16 '15 at 06:03
  • You don't need to do anything with the context, other then passing it to test functions. This is an abstract data type that is used by the library. Tests will run in parallel automatically (see `-runner` option). Anyway, here is a real world example, https://github.com/BinaryAnalysisPlatform/bap/blob/master/lib_test/bap_dwarf/test_leb128.ml – ivg Oct 16 '15 at 10:33