B0_testing
Simple testing tools.
module Test : sig ... end
Testing structure and combinators.
This is a typical test executable. The pattern here ensures that you can, case arising, load it in the toplevel and invoke the various tests manually.
open B0_testing
let test_string_get () =
Test.test "String.get" @@ fun () ->
Test.char (String.get "a" 0) 'a' ~__POS__;
Test.invalid_arg @@ (fun () -> String.get "" 0) ~__POS__;
()
let test_string_append () =
Test.test "String.append" @@ fun () ->
Test.string (String.cat "a" "b") "ab" ~__POS__;
()
let main () =
Test.main @@ fun () ->
test_string_get ();
test_string_append ();
()
let () = if !Sys.interactive then () else exit (main ())
Note that if you are in a testing hurry or migrating you can always simply use OCaml's assert
in the test functions: you just won't get any rendering on assertion failures and tests stop at the first assertion failure.