b0 test
The b0 test
command is a simple test runner for your B0.ml
file.
A test unit is a unit tagged with B0_meta.test
and B0_meta.run
and, for lengthy tests, the B0_meta.long
tag. Tests can be spotted by a T
in b0 list
; the non-lengthy ones are in green.
The operating principle of b0 test
is simple:
b0
invocation does.For example the following invocations build the default pack and execute the test units therein:
b0 test
b0 test -l # Do not skip the long tests
If any test exits with a non-zero error code, the b0 test
invocation eventually exits with 1
.
Adding option --what
to a b0 test
invocation reports what is build and which tests are executed.
b0 test --what # Show what builds and runs
For b0
the testing granularity is the executable unit. You can easily devise your own test sets via packs and the usual build selection options -u
, -p
, -x
and -X
. For example:
b0 test -p special-tests -x known_to_fail
Since tests are just executable units you can also run them individually with the usual b0
invocation:
b0 -- mytest
That's all there is to know about b0 and testing.
The infrastructure described above allows to hook the testing framework of your wish by simply tagging your test executables with B0_meta.test
and B0_meta.run
.
b0 itself provides a few testing tools to make such executables for OCaml:
B0_testing
in the b0.std
library simply runs tests as functions from unit -> unit
, provides a few asserting tools and integrates nicely with b0 test
's rendering.B0_expect
in the b0.kit
library provides expectation testing. It is expected to change a little bit in order to integrate better with b0 test
and B0_testing
.