|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Test suites are named groups of related test cases. More...
Classes | |
| class | micro_os_plus::micro_test_plus::located_name |
| A name of a suite or of a test case, with the location where it was given. More... | |
| class | micro_os_plus::micro_test_plus::static_suite |
| A test suite designed for static (namespace-scope) registration with a runner. More... | |
| class | micro_os_plus::micro_test_plus::suite |
| A named, runnable test suite registered with the test runner. More... | |
| class | micro_os_plus::micro_test_plus::top_suite |
| The optional top suite owned by every runner instance. More... | |
A suite has a name and a body, a function that creates its test cases. The suites are either added in main() with runner::add_suite(), or defined as static suites, and runner::run_suites() runs them all, sorted by name.
The top suite is a shortcut: a suite whose body is the code of main() itself. runner::add_top_suite() adds it and returns it, and the test cases created on it in main() run immediately, before runner::run_suites() is called. It therefore always runs before all the other suites, whatever their names. It is optional; a program may put all its test cases in the other suites.
A test case can be created only on the suite whose body is running: on the top suite from main(), or on the suite received by the body of another suite. A call on another suite, for example on the top suite captured in the body of another suite, is reported as a failure, and the test case is not run.
The static suites are mt::static_suite objects, defined at namespace scope, usually in separate source files, and constructed with a name, a reference to the runner, and a callable (usually a function or a lambda with a mt::suite& first parameter, which creates the test cases), along with any optional arguments. They register themselves in their constructors, so they are included in the test run without other calls.
A static suite does not need the runner to be constructed first; it can be defined in any source file, before or after the runner.
To set the order explicitly, start the names with zero-padded numbers ("01 - Init", "02 - Run"). Even so, write each suite so that it does not depend on the others having run before it.