module OUnit:sig
..end
To uses this library link with
ocamlc oUnit.cmo
or
ocamlopt oUnit.cmx
Author(s): Maas-Maarten Zeeman
Assertions are the basic building blocks of unittests.
val assert_failure : string -> 'a
Failure
to signal a failureval assert_bool : string -> bool -> unit
Failure
to signal a failureval (@?) : string -> bool -> unit
Failure
to signal a failureval assert_string : string -> unit
Failure
to signal a failureval assert_equal : ?cmp:('a -> 'a -> bool) ->
?printer:('a -> string) -> ?msg:string -> 'a -> 'a -> unit
Failure
descriptionval assert_raises : ?msg:string -> exn -> (unit -> 'a) -> unit
Failure
descriptionIn 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 function 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"
.val todo : string -> unit
val cmp_float : ?epsilon:float -> float -> float -> bool
A bracket is a functional implementation of the commonly used setUp and tearDown feature in unittests. It can be used like this:
"MyTestCase" >:: (bracket test_set_up test_fun test_tear_down)
val bracket : (unit -> 'a) -> ('a -> 'b) -> ('a -> 'c) -> unit -> 'c
typetest_fun =
unit -> unit
type
test =
| |
TestCase of |
| |
TestList of |
| |
TestLabel of |
val (>:) : string -> test -> test
val (>::) : string -> test_fun -> test
val (>:::) : string -> test list -> test
Examples:
"test1" >: TestCase((fun _ -> ()))
=>
TestLabel("test2", TestCase((fun _ -> ())))
"test2" >:: (fun _ -> ())
=>
TestLabel("test2", TestCase((fun _ -> ())))
"test-suite" >::: ["test2" >:: (fun _ -> ());]
=>
TestLabel("test-suite", TestSuite([TestLabel("test2", TestCase((fun _ -> ())))]))
val test_decorate : (test_fun -> test_fun) -> test -> test
test_decorate g tst
Apply g
to test function contains in tst
tree.val test_filter : string list -> test -> test option
test_filter paths tst
Filter test based on their path string representation.val test_case_count : test -> int
type
node =
| |
ListItem of |
| |
Label of |
typepath =
node list
val string_of_node : node -> string
val string_of_path : path -> string
val test_case_paths : test -> path list
type
test_result =
| |
RSuccess of |
| |
RFailure of |
| |
RError of |
| |
RSkip of |
| |
RTodo of |
type
test_event =
| |
EStart of |
| |
EEnd of |
| |
EResult of |
val perform_test : (test_event -> 'a) -> test -> test_result list
val run_test_tt : ?verbose:bool -> test -> test_result list
val run_test_tt_main : test -> test_result list