|
micro-test-plus 3.3.1
µTest++ Testing Framework
|
The test runner for the µTest++ framework. More...
#include <micro-os-plus/micro-test-plus.h>
Public Member Functions | |
| test_runner () | |
| Default constructor for the test_runner class. | |
| test_runner (const test_runner &)=delete | |
| Deleted copy constructor to prevent copying. | |
| test_runner (test_runner &&)=delete | |
| Deleted move constructor to prevent moving. | |
| ~test_runner ()=default | |
| Destructor for the test_runner class. | |
| void | abort (void) |
| Aborts test execution immediately. | |
| int | exit_code (void) |
| Returns 0 if all tests were successful, 1 otherwise. | |
| void | initialize (int argc, char *argv[], const char *name) |
| Initialises the test runner with command-line arguments and an optional suite name. | |
| constexpr const char * | name (void) |
| Retrieves the name of the default test suite. | |
| test_runner & | operator= (const test_runner &)=delete |
| Deleted copy assignment operator to prevent copying. | |
| test_runner & | operator= (test_runner &&)=delete |
| Deleted move assignment operator to prevent moving. | |
| void | register_test_suite (test_suite_base *suite) |
| Registers a test suite with the runner. | |
| size_t | test_suites_count (void) |
Public Attributes | |
| test_suite_base * | default_test_suite = nullptr |
| Pointer to the default test suite which groups the main tests. | |
| std::vector< test_suite_base * > * | test_suites |
| Pointer to the array of registered test suites. | |
| struct { | |
| size_t failed_checks = 0 | |
| Total number of failed checks in the test suite. More... | |
| size_t successful_checks = 0 | |
| Total number of successful checks in the test suite. More... | |
| size_t test_cases_count = 0 | |
| Total number of test cases in the test suite. More... | |
| } | totals |
Protected Attributes | |
| int | argc_ = 0 |
| Stores the argument count passed to the test runner. | |
| char ** | argv_ = nullptr |
| Stores the argument vector passed to the test runner. | |
| const char * | default_suite_name_ = "Test" |
| The name of the default test suite. | |
The test_runner class is responsible for managing the registration and execution of test suites within the µTest++ framework. It maintains a collection of test suites, each of which registers itself automatically upon construction, enabling seamless integration and execution of tests across different components and folders of a project.
The test runner provides methods for initialising the test environment, registering test suites, retrieving the runner's name, and determining the overall test result via an exit code. It also offers an abort mechanism for terminating test execution in exceptional circumstances.
All members and methods are defined within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.
Definition at line 98 of file test-runner.h.
| micro_os_plus::micro_test_plus::test_runner::test_runner | ( | ) |
The rule of five is enforced to prevent accidental copying or moving.
The constructor initialises a new instance of the test_runner class, preparing the test runner for managing test suites and cases within the µTest++ framework. If tracing is enabled, it outputs the function signature for diagnostic purposes. This setup ensures the test runner is ready to coordinate the registration, execution, and reporting of tests across all test cases and folders.
Definition at line 73 of file test-runner.cpp.
Referenced by test_runner(), test_runner(), operator=(), and operator=().
|
delete |
References test_runner().
|
delete |
References test_runner().
|
default |
References name().
| void micro_os_plus::micro_test_plus::test_runner::abort | ( | void | ) |
This method immediately terminates the process by invoking the standard C library abort() function. It is used to halt test execution in critical failure scenarios, ensuring that no further tests are run and that the cause of the failure can be promptly investigated. This approach provides a robust mechanism for enforcing strict test outcomes across all test cases and folders.
Definition at line 303 of file test-runner.cpp.
References abort().
Referenced by abort().
| int micro_os_plus::micro_test_plus::test_runner::exit_code | ( | void | ) |
Definition at line 218 of file test-runner.cpp.
References micro_os_plus::micro_test_plus::test_suite_base::begin_test_suite(), micro_os_plus::micro_test_plus::current_test_suite, default_test_suite, micro_os_plus::micro_test_plus::test_suite_base::end_test_suite(), micro_os_plus::micro_test_plus::test_suite_base::failed_checks, micro_os_plus::micro_test_plus::reporter, micro_os_plus::micro_test_plus::test_suite::run(), micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::test_suite_base::successful_checks, micro_os_plus::micro_test_plus::test_suite_base::test_cases_count(), test_suites, totals, and micro_os_plus::micro_test_plus::test_suite_base::was_successful().
| void micro_os_plus::micro_test_plus::test_runner::initialize | ( | int | argc, |
| char * | argv[], | ||
| const char * | name ) |
| argc | The argument count from main(). |
| argv | The argument vector from main(). |
| name | The name of the default test suite. |
This method initialises the test runner by capturing the command-line arguments and the default test suite name, configuring the framework for subsequent test execution. It parses the arguments to determine the desired verbosity level (normal, verbose, quiet, or silent) and applies this setting to the test reporter. The method also outputs build and environment information when appropriate, aiding diagnostics and transparency. Finally, it creates and registers the default test suite, preparing the framework to manage and execute all test cases and suites across the project’s folders.
Definition at line 97 of file test-runner.cpp.
References argc_, argv_, micro_os_plus::micro_test_plus::current_test_suite, default_suite_name_, default_test_suite, name(), micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::quiet, micro_os_plus::micro_test_plus::reporter, micro_os_plus::micro_test_plus::silent, and micro_os_plus::micro_test_plus::verbose.
|
inlineconstexpr |
Definition at line 186 of file test-runner.h.
References default_suite_name_.
Referenced by ~test_runner(), and initialize().
|
delete |
References test_runner().
|
delete |
References test_runner().
| void micro_os_plus::micro_test_plus::test_runner::register_test_suite | ( | test_suite_base * | suite | ) |
| suite | Pointer to the test suite to register. |
This method registers a new test suite with the test runner. If the internal collection of test suites has not yet been created, it is initialised at this point. The provided test suite is then added to the collection, enabling the framework to manage and execute multiple test suites across different files and folders within the project.
Called by test suite constructors to register themselves with the runner, enabling automatic management and execution.
Definition at line 279 of file test-runner.cpp.
References micro_os_plus::micro_test_plus::test_suite_base::index, and test_suites.
|
inline |
Definition at line 172 of file test-runner.h.
References test_suites.
|
protected |
Definition at line 253 of file test-runner.h.
Referenced by initialize().
|
protected |
Definition at line 258 of file test-runner.h.
Referenced by initialize().
|
protected |
Definition at line 263 of file test-runner.h.
Referenced by initialize(), and name().
| test_suite_base* micro_os_plus::micro_test_plus::test_runner::default_test_suite = nullptr |
Definition at line 247 of file test-runner.h.
Referenced by exit_code(), and initialize().
| size_t micro_os_plus::micro_test_plus::test_runner::failed_checks = 0 |
Definition at line 224 of file test-runner.h.
| size_t micro_os_plus::micro_test_plus::test_runner::successful_checks = 0 |
Definition at line 219 of file test-runner.h.
| size_t micro_os_plus::micro_test_plus::test_runner::test_cases_count = 0 |
Definition at line 229 of file test-runner.h.
| std::vector<test_suite_base*>* micro_os_plus::micro_test_plus::test_runner::test_suites |
Statically initialised to zero as BSS, such that test suites defined as static objects in different compilation units can be automatically executed.
Definition at line 212 of file test-runner.h.
Referenced by exit_code(), register_test_suite(), and test_suites_count().
| struct { ... } micro_os_plus::micro_test_plus::test_runner::totals |
Referenced by exit_code().