module Make:
Parameters: |
|
val register : ?get_location:(unit -> unit) -> unit Utest.Only_in_test.t -> unit
register ?get_location test
registers a unit-test that triggers errors
via asserts (either regular or via the Asserts library).
(The get_location
argument is a hack; if you pass in (fun () -> assert
false)
, it will extract the location of the test from the assertion
failure.)
Example use (supposing the functions in the comment above were defined in
some module M
):
let () = UTest.register ~get_location:(fun () -> assert false)) (
let (>>=) = Only_in_test.(>>=) in
let (>>|) = Only_in_test.(>>|) in
M.test_of_int 23 >>= fun m ->
M.test_special_value >>= fun special_m ->
...
assert (condition1);
assert (condition2);
...
)
When run_tests_and_exit
is run, all unit tests that have been registered will be
run. Any assertion failures will be reported, together with their
locations.
If you pass in a file_name
, you will be able to run all tests registered
with the same file_name in a batch; similarly with test_name
. See the
comment on run_tests_and_exit
below.
val register_thunk : ?get_location:(unit -> unit) -> (unit -> unit) -> unit
register_thunk
is the same as register
, except that it applies
Only_in_test.of_thunk
to the test for you.val run_tests_and_exit : unit -> unit
run_tests_and_exit
Run all tests registered with register
. Statistics
are reported, and exit
is called after it's done. It exits with status
1 if any test fails (i.e., any assertion failure or other exception is
raised in the running of a test.)val run_tests : unit -> bool
run_tests
but returns false if one of the tests fails