The test_suite
Class Reference
Represents a named group of test cases that self-register to the runner. More...
Declaration
class micro_os_plus::micro_test_plus::test_suite
Included Headers
#include <micro-os-plus/micro-test-plus.h>
Base class
class | test_suite_base |
Base class for all test suites. More... | |
Public Constructors Index
template <typename Callable_T, typename... Args_T> | |
test_suite (const char *name, Callable_T &&callable, Args_T &&... arguments) | |
Class template constructor for test_suite. More... | |
test_suite (const test_suite &)=delete | |
Deleted copy constructor to prevent copying. More... | |
test_suite (test_suite &&)=delete | |
Deleted move constructor to prevent moving. More... | |
Public Destructor Index
~test_suite () override | |
Virtual destructor for the test_suite class. More... | |
Public Operators Index
test_suite & | operator= (const test_suite &)=delete |
Deleted copy assignment operator to prevent copying. More... | |
test_suite & | operator= (test_suite &&)=delete |
Deleted move assignment operator to prevent moving. More... | |
Public Member Functions Index
void | begin_test_case (const char *name) |
Marks the beginning of a named test case. More... | |
void | begin_test_suite (void) |
Begins the execution of the test suite. More... | |
void | end_test_case (void) |
Marks the end of a test case. More... | |
void | end_test_suite (void) |
Marks the end of the test suite. More... | |
constexpr int | failed_checks (void) |
Gets the number of test conditions that failed. More... | |
void | increment_failed (void) |
Increments the count of failed test conditions. More... | |
void | increment_successful (void) |
Increments the count of passed test conditions. More... | |
constexpr const char * | name (void) |
Gets the suite name. More... | |
void | run (void) override |
Runs the sequence of test cases in the suite by invoking the stored callable. More... | |
constexpr int | successful_checks (void) |
Gets the number of conditions that passed. More... | |
constexpr int | test_cases (void) |
Gets the number of test cases. More... | |
constexpr bool | unused (void) |
Checks if the test suite was not used. More... | |
constexpr bool | was_successful (void) |
Gets the test suite result. More... | |
Public Member Attributes Index
struct { ... } | current_test_case |
Structure holding the current test case's check counters. More... | |
int | failed_checks |
Number of failed checks in the current test case. More... | |
bool | process_deferred_begin = true |
Indicates whether to process deferred begin for test cases. More... | |
int | successful_checks |
Number of successful checks in the current test case. More... | |
Protected Member Attributes Index
std::function< void(void)> | callable_ |
Callable object representing the test suite's execution logic. More... | |
int | failed_checks_ = 0 |
Count of test conditions that failed. More... | |
const char * | name_ |
The test suite name. More... | |
int | successful_checks_ = 0 |
Count of test conditions that passed. More... | |
const char * | test_case_name_ |
The current test case name. More... | |
int | test_cases_ = 0 |
Count of test cases in the test suite. More... | |
Description
Represents a named group of test cases that self-register to the runner.
The test_suite
class extends test_suite_base
and enables the registration and execution of callable objects (such as lambdas or function pointers) as test suites. Upon construction, each test suite automatically registers itself with the test runner, facilitating automated test discovery and execution across different components and folders of a project.
This class template provides a flexible mechanism for grouping related test cases and managing their execution within the µTest++ framework. It ensures that test suites are non-copyable and non-movable, maintaining unique ownership and consistent state.
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 371 of file test-suite.h.
Public Constructors
test_suite()
|
Class template constructor for test_suite.
- Template Parameters
Callable_T The type of a callable object. Args_T The types of the callable arguments.
- Parameters
[in] name The test case name or description, used in reports. [in] callable A generic callable object, usually a lambda, invoked to perform the test. [in] arguments A possibly empty list of arguments to be passed to the callable.
The rule of five is enforced to prevent accidental copying or moving.
This constructor initialises a test suite by binding the provided callable and its arguments, and registers the suite with the test runner.
The callable is bound using std::bind
, allowing for flexible test suite definitions with arbitrary arguments. Upon construction, the test suite is automatically registered with the global runner for execution.
Declaration at line 390 of file test-suite.h, definition at line 88 of file test-suite-inlines.h.
test_suite()
| delete |
Deleted copy constructor to prevent copying.
Definition at line 396 of file test-suite.h.
test_suite()
| delete |
Deleted move constructor to prevent moving.
Definition at line 401 of file test-suite.h.
Public Destructor
~test_suite()
| virtual |
Virtual destructor for the test_suite class.
The destructor releases any resources associated with the test_suite
instance. If tracing is enabled, it outputs the function signature for diagnostic purposes. This ensures that the test suite is properly cleaned up after execution, supporting robust and reliable test management across all files and folders within the µTest++ framework.
Declaration at line 420 of file test-suite.h, definition at line 241 of file test-suite.cpp.
Public Operators
operator=()
| delete |
Deleted copy assignment operator to prevent copying.
Definition at line 407 of file test-suite.h.
operator=()
| delete |
Deleted move assignment operator to prevent moving.
Definition at line 414 of file test-suite.h.
Public Member Functions
begin_test_case()
|
Marks the beginning of a named test case.
- Parameters
[in] name The test case name.
- Returns
Nothing.
This method marks the beginning of a test case within the suite. If the start of the suite was deferred, it ensures the suite is properly begun before proceeding. The method sets the current test case name, increments the total number of test cases, resets the current test case statistics, and notifies the test reporter to begin the test case. This approach guarantees that each test case is clearly identified, accurately tracked, and properly reported across all test cases and folders.
Declaration at line 158 of file test-suite.h, definition at line 159 of file test-suite.cpp.
begin_test_suite()
|
Begins the execution of the test suite.
- Parameters
None.
- Returns
Nothing.
This method marks the beginning of a test suite's execution. It resets the deferred begin flag and notifies the test reporter to start the suite, passing the suite's name. This ensures that test suite output is clearly delineated and properly initialised, supporting organised and readable reporting across all test cases and folders.
Declaration at line 253 of file test-suite.h, definition at line 122 of file test-suite.cpp.
end_test_case()
|
Marks the end of a test case.
- Parameters
None.
- Returns
Nothing.
This method marks the end of a test case within the suite. It notifies the test reporter to conclude the test case, passing the current test case name. This ensures that the results of the test case are accurately finalised and clearly reported, supporting organised and reliable test management across all test cases and folders.
Declaration at line 168 of file test-suite.h, definition at line 183 of file test-suite.cpp.
end_test_suite()
|
Marks the end of the test suite.
- Parameters
None.
- Returns
Nothing.
This method marks the end of a test suite's execution. If the suite's start was deferred, it ensures the suite is properly begun before finalising. The method then notifies the test reporter to conclude the suite, passing a reference to the suite instance. This guarantees that all results are accurately summarised and reported, supporting clear and organised test management across all test cases and folders.
Declaration at line 264 of file test-suite.h, definition at line 139 of file test-suite.cpp.
failed_checks()
| inlinenodiscardconstexpr |
Gets the number of test conditions that failed.
- Parameters
None.
- Returns
An integer with the number of checks that failed.
Definition at line 226 of file test-suite.h.
increment_failed()
|
Increments the count of failed test conditions.
- Parameters
None.
- Returns
Nothing.
This method increments the count of failed checks for the test suite and the current test case. It ensures that each failing assertion is accurately recorded, supporting precise tracking and reporting of test outcomes across all test cases and folders.
Declaration at line 203 of file test-suite.h, definition at line 210 of file test-suite.cpp.
increment_successful()
|
Increments the count of passed test conditions.
- Parameters
None.
- Returns
Nothing.
This method increments the count of successful checks for the test suite and the current test case. It ensures that each passing assertion is accurately recorded, supporting precise tracking and reporting of test outcomes across all test cases and folders.
Declaration at line 192 of file test-suite.h, definition at line 196 of file test-suite.cpp.
name()
| inlinenodiscardconstexpr |
Gets the suite name.
- Parameters
None.
- Returns
A pointer to the null-terminated test suite name.
Definition at line 178 of file test-suite.h.
run()
| virtual |
Runs the sequence of test cases in the suite by invoking the stored callable.
- Parameters
None.
- Returns
Nothing.
This method executes the test suite by invoking the stored callable object associated with the suite. It ensures that all test cases registered within the suite are executed in sequence, supporting comprehensive and structured testing across all files and folders within the µTest++ framework.
Declaration at line 432 of file test-suite.h, definition at line 227 of file test-suite.cpp.
successful_checks()
| inlinenodiscardconstexpr |
Gets the number of conditions that passed.
- Parameters
None.
- Returns
An integer with the number of checks that passed.
Definition at line 213 of file test-suite.h.
test_cases()
| inlinenodiscardconstexpr |
Gets the number of test cases.
- Parameters
None.
- Returns
An integer with the number of test cases.
Definition at line 239 of file test-suite.h.
unused()
| inlinenodiscardconstexpr |
Checks if the test suite was not used.
- Parameters
None.
- Returns
True if the test suite is not used.
Definition at line 288 of file test-suite.h.
was_successful()
| inlinenodiscardconstexpr |
Gets the test suite result.
- Parameters
None.
- Returns
True if the test suite was successful.
Definition at line 274 of file test-suite.h.
Public Member Attributes
current_test_case
|
Structure holding the current test case's check counters.
Tracks the number of successful and failed checks for the currently running test case.
Definition at line 344 of file test-suite.h.
failed_checks
|
Number of failed checks in the current test case.
Definition at line 343 of file test-suite.h.
process_deferred_begin
|
Indicates whether to process deferred begin for test cases.
Definition at line 324 of file test-suite.h.
successful_checks
|
Number of successful checks in the current test case.
Definition at line 338 of file test-suite.h.
Protected Member Attributes
callable_
| protected |
Callable object representing the test suite's execution logic.
Definition at line 438 of file test-suite.h.
failed_checks_
| protected |
Count of test conditions that failed.
Definition at line 313 of file test-suite.h.
name_
| protected |
The test suite name.
Definition at line 298 of file test-suite.h.
successful_checks_
| protected |
Count of test conditions that passed.
Definition at line 308 of file test-suite.h.
test_case_name_
| protected |
The current test case name.
Definition at line 303 of file test-suite.h.
test_cases_
| protected |
Count of test cases in the test suite.
Definition at line 318 of file test-suite.h.
The documentation for this class was generated from the following files:
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.