dimanche 29 mars 2015

OCaml OUnit bracket example: setup and tear-down

Don't really get how to use bracket setup and tear-down with OUnit. Anyone feel like supplying an example?


This is the OUnit2.bracket function signature:



val bracket : (test_ctxt -> 'a) ->
('a -> test_ctxt -> unit) -> test_ctxt -> 'a

bracket set_up tear_down test_ctxt set up an object and register it to be tore down in test_ctxt.


You setup a test suite like this:



let test_suite =
"suite" >::: [
"test1" >:: test1_fun
]


And run it like this:



let _ =
run_test_tt_main test_suite


Where do I put the bracket in this work-flow?


Link to OUnit docs: http://ift.tt/19xBcrC


Aucun commentaire:

Enregistrer un commentaire