runnable_base Class
Non-template base for all runnable objects (suites and subtests). More...
Declaration
Included Headers
Base class
| class | test_node |
|
Base class for runners and runable tests. More... | |
Derived Classes
| class | runnable<Self_T> |
|
CRTP base class factoring out callable storage, rule-of-five, and run() logic shared by subtest and suite. More... | |
| class | runnable<Self_T> |
|
CRTP base class factoring out callable storage, rule-of-five, and run() logic shared by subtest and suite. More... | |
| class | runnable<Self_T> |
|
CRTP base class factoring out callable storage, rule-of-five, and run() logic shared by subtest and suite. More... | |
Public Constructors Index
| runnable_base (const char *name, runner &runner, size_t own_index) | |
|
Constructs a runnable_base with a name, runner, and index. More... | |
| runnable_base (const runnable_base &)=delete | |
|
Deleted copy constructor to prevent copying. More... | |
| runnable_base (runnable_base &&)=delete | |
|
Deleted move constructor to prevent moving. More... | |
Public Destructor Index
| ~runnable_base () override | |
|
Virtual destructor. More... | |
Public Operators Index
| runnable_base & | operator= (const runnable_base &)=delete |
|
Deleted copy assignment operator to prevent copying. More... | |
| runnable_base & | operator= (runnable_base &&)=delete |
|
Deleted move assignment operator to prevent moving. More... | |
Public Member Functions Index
| void | abort (const reflection::source_location &sl=reflection::source_location::current()) |
|
Aborts test execution via the owning runner. More... | |
| size_t | children_subtests_count (void) const noexcept |
|
Returns the number of direct child subtests owned by this node. More... | |
| size_t | current_subtest_index () const noexcept |
|
Returns the index of the most recently created child subtest. More... | |
| size_t | increment_subtest_index () noexcept |
|
Increments and returns the child subtest sequential index. More... | |
| const char * | name (void) const noexcept |
|
Gets the node name. More... | |
| size_t | own_index () const noexcept |
|
Returns the positional index of this object within its parent. More... | |
| void | own_index (size_t index) noexcept |
|
Sets the positional index of this object within its parent. More... | |
| class reporter & | reporter (void) const noexcept |
|
Gets the test reporter associated with this test runnable. More... | |
| class runner & | runner (void) const noexcept |
|
Gets the test runner associated with this test runnable. More... | |
| const runner_totals & | totals () const noexcept |
|
Gets the totals for the test (const overload). More... | |
| runner_totals & | totals () noexcept |
|
Gets the totals for the test. More... | |
Protected Member Functions Index
| void | after_subtest_create_ (std::unique_ptr< subtest > child_test, suite &suite) |
|
Registers a newly constructed child subtest and executes it immediately. More... | |
Protected Member Attributes Index
| std::vector< std::unique_ptr< subtest > > | children_subtests_ |
|
Owning collection of direct child subtests. More... | |
| size_t | current_subtest_index_ = 0 |
|
The subtest index, counting from 1. More... | |
| const char * | name_ |
|
The test node name. More... | |
| size_t | own_index_ |
|
The test index, counting from 1. More... | |
| class { ... } | runner_ |
|
Reference to the test runner that owns this object. More... | |
| runner_totals | totals_ |
|
Totals for the test node, including nested cases. More... | |
Description
Non-template base for all runnable objects (suites and subtests).
runnable_base extends test_node with the state that is shared by every runnable object but does not depend on the CRTP self-type:
- a reference to the owning runner,
- the object's own index within its parent container,
- a sequential subtest index used when creating nested subtests, and
- an owning vector of child subtest instances.
Concrete runnable classes (suite, subtest) derive from runnable<Self_T> which in turn derives from runnable_base.
The class is non-copyable and non-movable to preserve unique ownership and consistent state throughout the test session.
Definition at line 262 of file test.h.
Public Constructors
runnable_base()
|
Constructs a runnable_base with a name, runner, and index.
- Parameters
-
name The name used in reports.
runner The test runner managing this object.
own_index The positional index of this object within its parent.
The constructor initialises a new instance of the runnable_base class with the specified name. It sets up the internal state required for managing test cases within the suite. If tracing is enabled, the function signature is output for diagnostic purposes. The default test suite does not require explicit registration, ensuring seamless integration within the µTest++ framework and supporting organised test management across all files and folders.
Declaration at line 273 of file test.h, definition at line 118 of file test.cpp.
References micro_os_plus::micro_test_plus::detail::test_node::test_node, micro_os_plus::micro_test_plus::detail::test_node::name, own_index, own_index_, runner and runner_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable< Self_T >::runnable, runnable_base, runnable_base, operator= and operator=.
runnable_base()
| delete |
Deleted copy constructor to prevent copying.
Definition at line 278 of file test.h.
Reference runnable_base.
runnable_base()
| delete |
Deleted move constructor to prevent moving.
Definition at line 283 of file test.h.
Reference runnable_base.
Public Destructor
~runnable_base()
| virtual |
Virtual destructor.
The destructor releases any resources associated with the runnable_base instance. It 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 302 of file test.h, definition at line 134 of file test.cpp.
Reference micro_os_plus::micro_test_plus::detail::test_node::name_.
Public Operators
operator=()
| delete |
Deleted copy assignment operator to prevent copying.
Definition at line 289 of file test.h.
Reference runnable_base.
operator=()
| delete |
Deleted move assignment operator to prevent moving.
Definition at line 296 of file test.h.
References runnable_base, abort, after_subtest_create_, children_subtests_count, current_subtest_index, increment_subtest_index, own_index, reporter and runner.
Public Member Functions
abort()
|
Aborts test execution via the owning runner.
- Parameters
-
sl The source location from which the abort is triggered.
- Returns
Does not return.
Delegates immediately to runner_.abort(), passing the supplied source location so that the error message identifies the call site before the process is terminated via ::abort().
Declaration at line 378 of file test.h, definition at line 161 of file test.cpp.
Reference runner_.
Referenced by operator=.
children_subtests_count()
| inline nodiscard noexcept |
Returns the number of direct child subtests owned by this node.
- Parameters
None.
- Returns
The number of child subtests.
Returns the number of child subtests owned by this node.
Declaration at line 358 of file test.h, definition at line 168 of file test-inlines.h.
Reference children_subtests_.
Referenced by micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_suite and operator=.
current_subtest_index()
| inline nodiscard noexcept |
Returns the index of the most recently created child subtest.
- Parameters
None.
- Returns
The current child subtest sequential index.
Returns the sequential index of the most recently created child subtest.
Declaration at line 338 of file test.h, definition at line 146 of file test-inlines.h.
Reference current_subtest_index_.
Referenced by operator=, micro_os_plus::micro_test_plus::reporter_tap::output_fail_prefix_ and micro_os_plus::micro_test_plus::reporter_tap::output_pass_prefix_.
increment_subtest_index()
| inline noexcept |
Increments and returns the child subtest sequential index.
- Parameters
None.
- Returns
The new index value after incrementing.
Each call to test() invokes this method before constructing the new subtest, so the index values form a strictly increasing, one-based sequence.
Declaration at line 348 of file test.h, definition at line 158 of file test-inlines.h.
Reference current_subtest_index_.
Referenced by operator=.
name()
| inline nodiscard noexcept |
Gets the node name.
- Parameters
None.
- Returns
A pointer to the null-terminated test node name.
Returns a pointer to the null-terminated name stored in name_.
Declaration at line 203 of file test.h, definition at line 94 of file test-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::test_node::name_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable< Self_T >::runnable, runnable_base, micro_os_plus::micro_test_plus::runner::runner, micro_os_plus::micro_test_plus::runner::runner, micro_os_plus::micro_test_plus::static_runner::static_runner, micro_os_plus::micro_test_plus::static_runner::static_runner, micro_os_plus::micro_test_plus::detail::test_node::test_node, after_subtest_create_, micro_os_plus::micro_test_plus::reporter_human::begin_subtest, micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, micro_os_plus::micro_test_plus::reporter_human::begin_suite, micro_os_plus::micro_test_plus::reporter_tap::begin_suite, micro_os_plus::micro_test_plus::reporter_human::end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_human::end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite, micro_os_plus::micro_test_plus::runner::operator= and micro_os_plus::micro_test_plus::runner::suite.
own_index()
| inline nodiscard noexcept |
Returns the positional index of this object within its parent.
- Parameters
None.
- Returns
The one-based own index.
Returns the one-based positional index of this object within its parent.
Declaration at line 314 of file test.h, definition at line 126 of file test-inlines.h.
Reference own_index_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable< Self_T >::runnable, runnable_base, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_suite and operator=.
own_index()
| inline noexcept |
Sets the positional index of this object within its parent.
This overload follows the same-name getter/setter pattern used throughout the framework: the getter is the const overload and the setter is the non-const single-argument overload.
- Parameters
-
index The new index value.
- Returns
Nothing.
Sets the positional index of this object within its parent.
Declaration at line 328 of file test.h, definition at line 136 of file test-inlines.h.
Reference own_index_.
reporter()
| nodiscard noexcept |
Gets the test reporter associated with this test runnable.
- Parameters
None.
- Returns
A reference to the test reporter.
Delegates immediately to runner_.reporter(), returning the reporter associated with the owning runner instance.
Declaration at line 368 of file test.h, definition at line 149 of file test.cpp.
Reference runner_.
Referenced by operator=.
runner()
| inline nodiscard noexcept |
Gets the test runner associated with this test runnable.
- Parameters
None.
- Returns
A reference to the test runner.
Returns a reference to the owning test runner.
Declaration at line 389 of file test.h, definition at line 178 of file test-inlines.h.
Reference runner_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable< Self_T >::runnable, runnable_base and operator=.
totals()
| inline nodiscard noexcept |
Gets the totals for the test (const overload).
- Parameters
None.
- Returns
A const reference to the runner_totals instance.
Returns a const reference to the runner_totals member.
Declaration at line 224 of file test.h, definition at line 114 of file test-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::test_node::totals_.
totals()
| inline nodiscard noexcept |
Gets the totals for the test.
- Parameters
None.
- Returns
A reference to the runner_totals instance.
Returns a reference to the runner_totals member.
Declaration at line 214 of file test.h, definition at line 104 of file test-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::test_node::totals_.
Referenced by after_subtest_create_, micro_os_plus::micro_test_plus::reporter_human::end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session, micro_os_plus::micro_test_plus::reporter_human::end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_human::end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite and micro_os_plus::micro_test_plus::detail::test_node::operator=.
Protected Member Functions
after_subtest_create_()
| protected |
Registers a newly constructed child subtest and executes it immediately.
- Parameters
-
child_test Owning pointer to the newly created subtest.
suite The parent suite to which execution results are reported.
- Returns
Nothing.
Transfers ownership of child_test into children_subtests_ and immediately invokes subtest::run() on the newly stored subtest. The parent's executed-subtest counter is then incremented. The child's check counters are intentionally not merged into the parent totals; each subtest reports only its own counters. The child's totals are, however, accumulated into suite so that the suite summary reflects all checks performed by its subtests.
Declaration at line 403 of file test.h, definition at line 177 of file test.cpp.
References children_subtests_, micro_os_plus::micro_test_plus::detail::runner_totals::increment_executed_subtests, micro_os_plus::micro_test_plus::detail::test_node::name, micro_os_plus::micro_test_plus::subtest::run and micro_os_plus::micro_test_plus::detail::test_node::totals.
Referenced by operator=.
Protected Member Attributes
children_subtests_
| protected |
Owning collection of direct child subtests.
Each call to test() appends a new subtest to this vector and runs it immediately. The vector retains ownership for the lifetime of the parent runnable.
Definition at line 436 of file test.h.
Referenced by after_subtest_create_ and children_subtests_count.
current_subtest_index_
| protected |
The subtest index, counting from 1.
This index is used for reporting and tracking the execution order of subtests within a suite, especially when nested subtests are involved. It is incremented for each subtest created, allowing for clear identification of subtests in reports and diagnostics.
Definition at line 426 of file test.h.
Referenced by current_subtest_index and increment_subtest_index.
name_
| protected |
The test node name.
Derived classes may access this member directly in addition to the public name() getter.
Definition at line 233 of file test.h.
Referenced by micro_os_plus::micro_test_plus::detail::test_node::test_node, micro_os_plus::micro_test_plus::detail::runnable< Self_T >::~runnable, ~runnable_base, micro_os_plus::micro_test_plus::detail::test_node::~test_node and micro_os_plus::micro_test_plus::detail::test_node::name.
own_index_
| protected |
The test index, counting from 1.
Definition at line 415 of file test.h.
Referenced by runnable_base, own_index and own_index.
runner_
| protected |
totals_
| protected |
Totals for the test node, including nested cases.
Definition at line 238 of file test.h.
Referenced by micro_os_plus::micro_test_plus::runner::exit_code, micro_os_plus::micro_test_plus::runner::run_suites_, micro_os_plus::micro_test_plus::static_runner::run_suites_, micro_os_plus::micro_test_plus::detail::test_node::totals and micro_os_plus::micro_test_plus::detail::test_node::totals.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.