In certain condition test can be written but there is no point running it, because they are not significant (missing OS features for example). In this case this is not a failure nor a success. Following functions allow you to escape test, just as assertion but without the same error status.
A test skipped is counted as success. A test todo is counted as failure.
val skip_if : bool ->string -> unit
skip cond msg If cond is true, skip the test for the reason explain in msg. For example skip_if (Sys.os_type = "Win32") "Test a doesn't run on
windows".
since 1.0.3
val todo : string -> unit
The associated test is still to be done, for the reason given.
since 1.0.3
Compare Functions
val cmp_float : ?epsilon:float ->float ->float -> bool
Compare floats up to a given relative error.
parameterepsilon
if the difference is smaller epsilon values are equal
Bracket
A bracket is a functional implementation of the commonly used setUp and tearDown feature in unittests. It can be used like this:
val bracket : (unit ->'a)->('a-> unit)->('a-> unit)->unit -> unit
bracket set_up test tear_down The set_up function runs first, then the test function runs and at the end tear_down runs. The tear_down function runs even if the test failed and help to clean the environment.
val bracket_tmpfile :
?prefix:string ->?suffix:string ->?mode:open_flag list->((string * out_channel)-> unit)->unit ->
unit
bracket_tmpfile test The test function takes a temporary filename and matching output channel as arguments. The temporary file is created before the test and removed after the test.