Skip to main content

Test Runners

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

Classes Index

classrunner

The test runner for the µTest++ framework. More...

classstatic_runner

A runner variant that also manages statically-registered test suites. More...

Description

Classes for initialising the framework and returning an exit code.

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 ();
 }

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.


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.