Function libtest_mimic::run_tests[][src]

pub fn run_tests<D>(
    args: &Arguments,
    tests: Vec<Test<D>>,
    run_test: impl Fn(&Test<D>) -> Outcome
) -> Conclusion

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 to stdout and stderr, 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 uses println!() and friends, it might be impossible to capture the output.

Currently, the following CLI args are ignored, but are planned to be used in the future:

  • --test-threads
  • --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.