micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
Test Runners

Classes for initialising the framework and returning an exit code. More...

Classes

class  micro_os_plus::micro_test_plus::runner
 The test runner for the µTest++ framework. More...
class  micro_os_plus::micro_test_plus::static_runner
 A runner variant that also manages statically-registered test suites. More...

Detailed Description

Proper initialisation ensures that µTest++ is correctly configured to manage and execute test cases, whilst the exit code reflects the overall test outcome and supports integration with automated build and continuous integration systems.

The simplest test consists of the default test suite and a single test case with one expectation; for example:

int
main (int argc, char* argv[])
{
mt::runner tr;
auto& ts = tr.initialise (argc, argv, "Minimal");
ts.test ("Check truth", [] (auto& t) {
t.expect (true);
});
return tr.exit_code ();
}
Main C++ header with the declarations for the µTest++ Testing Framework.
Primary namespace for the µTest++ testing framework.

When this test is executed, the output is as follows:

TAP version 14
# Subtest: Minimal
# Subtest: Check truth
ok 1 - true
1..1
ok 1 - Check truth # { passed, 1 check }
1..1
ok 1 - Minimal # { passed, 1 check in 1 test case, time: 0.065 ms }
1..1
# { total: 1 check passed, 0 failed, in 1 test case, 1 test suite, time: 0.136 ms }

The name passed to the initialiser is optional; if missing, it will attempt to extract a name from argv[0], which is commonly the executable name. If that fails, a default name is used.