Function libtest_mimic::run_tests
source · [−]pub fn run_tests<D: 'static + Send + Sync>(
args: &Arguments,
tests: Vec<Test<D>>,
run_test: impl Fn(&Test<D>) -> Outcome + 'static + Send + Sync
) -> Conclusion
Expand description
Runs all given tests with the given test runner.
This is the central function of this crate. It provides the framework for the testing harness. It does all the printing and house keeping.
This function tries to respect most options configured via CLI args. For example, filtering, output format and coloring are respected. However, some things cannot be handled by this function and you (as a user) need to take care of it yourself. The following options are ignored by this function and need to be manually checked:
--nocapture
and capturing in general. It is expected that during the test, nothing writes tostdout
andstderr
, unless--nocapture
was specified. If the test is ran as a seperate process, this is fairly easy. If however, the test is part of the current application and it usesprintln!()
and friends, it might be impossible to capture the output.
Currently, the following CLI arg is ignored, but is planned to be used in the future:
--format=json
. If specified, this function will panic.
All other flags and options are used properly.
The returned value contains a couple of useful information. See the
Conclusion
documentation for more information. If --list
was
specified, a list is printed and a dummy Conclusion
is returned.