Skip to main content

µTest++ Testing Framework API Reference

The µTest++ Testing Framework topics, with their brief descriptions, are:

µOS++ Topics Topics related to the µOS++ framework
µTest++ The µTest++ Testing Framework
C++ API How to write the tests
Test runners The runner initialises the framework and returns the exit code
Test suites Test suites are named groups of related test cases
Test cases Test cases are named sequences of checks
Expectations Expectations are checks whose outcomes are counted and reported
Requirements Requirements are checks that stop the test case when they fail
Function comparators Functions for comparing actual and expected values in tests
Logical functions Functions used to compose logical expressions in tests
Checking exceptions Functions for verifying exceptions in test cases
Utility functions Utility functions for handling strings in tests
Customisation Reporting the application types, and writing application comparators
Deprecated Definitions kept for compatibility with earlier releases
Operators Deprecated overloaded operators for test comparisons
Old logical function names Deprecated v5.0.1 names of the logical functions
Literals and wrappers Deprecated literal operators and wrappers for typed operands
C API There is no C API; C code is tested from C++
Configuration The macros that enable and configure the framework
Command-line options Options for controlling the test output at run time

Description​

The µTest++ project is a C++20 testing framework for embedded systems, which also runs on the native platforms. The tests are ordinary C++ code, with no preprocessor macros, organised in test suites and test cases.

The results are written in the TAP (Test Anything Protocol) format by default, which the continuous integration systems and the TAP tools read. A human-readable format is also available, for reading the results on the console.

The command-line options select the format, how much is displayed (from nothing, with only the exit code, to every check), the colours, an output file, and the test cases to run.

Getting started​

The applications include a single header, micro-os-plus/micro-test-plus.h. The header declares nothing unless the macro MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED is defined, preferably in micro-os-plus/micro-test-plus-defines.h, for the application and for the library sources (see Configuration).

A complete test program has a runner, initialised with the command-line arguments, a top suite created in main() (optional, since the suites can be added to the runner instead), test cases with checks, and returns the exit code of the session:

 
 
 mt::runner tr;
 
 int
 main (int argc, char* argv[])
 {
  tr.initialise (argc, argv);
 
  auto& ts = tr.add_top_suite ();
 
  ts.test ("Check truth", [] (auto& t) {
  t.expect (mt::eq (6 * 7, 42)) << "the answer is 42";
  });
 
  return tr.run_suites ();
 }

The topics of the C++ API group describe the runner, the suites, the test cases, and the checks, and the Command-line options group the options of the test programs. The main classes are runner, runner_options, suite, and test_case. The installation, the first project, and the user manual are in the Getting Started and User's Guide pages of the site.

note

For comparison, the original Doxygen html pages continue to be available via the .../doxygen/*.html URLs.


Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.