The Initialisation & Exit Reference
Functions for initialising the framework and returning an exit code. More...
Functions Index
int | exit_code (void) |
Complete the test run and return the exit code. More... | |
void | initialize (int argc, char *argv[], const char *name="Main") |
Initialise the µTest++ framework. More... | |
Description
Functions for initialising the framework and returning an exit code.
These functions are responsible for initialising the test runner and returning the test result as the process exit code. Proper initialisation ensures that the µTest++ framework is correctly configured to manage and execute test cases, while the exit code reflects the overall outcome of the tests, supporting integration with automated build and continuous integration systems.
The simplest test consists of a single test case containing a single expectation; for example:
When this test is executed, the output is as follows:
Functions
exit_code()
| nodiscard |
Complete the test run and return the exit code.
- Parameters
None.
- Returns
0 if all tests were successful, 1 if any test failed.
In addition to the test cases defined in main()
, additional test suites may be declared as static objects either within the same file or in other files, and are automatically registered via the static constructors mechanism.
The exit_code
function finalises the execution of all registered test suites and test cases within the µTest++ framework, and returns an appropriate exit code to the operating system. This function should be called at the end of the test program, typically from the main()
function, to ensure that all results are properly reported and the correct status is communicated.
The returned value indicates the overall success or failure of the test run, allowing integration with build systems and continuous integration environments.
Definition at line 108 of file micro-test-plus.cpp.
initialize()
|
Initialise the µTest++ framework.
- Parameters
[in] argc The number of command-line arguments. [in] argv Array of pointers to null-terminated argument strings. [in] name The name of the default test suite. Defaults to "Main"
if not specified.
- Returns
Nothing.
The initialize
function sets up the µTest++ testing framework, preparing it for test execution. It processes command-line arguments, configures the test environment, and establishes the default test suite name. This function should be called at the beginning of the test programme, typically from the main()
function, to ensure proper initialisation of all framework components.
The provided arguments may be used to configure verbosity or other run-time options for the test session.
Definition at line 81 of file micro-test-plus.cpp.
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.