counters Class
Aggregated check and test case counters for a node in the test tree. More...
Declaration
Included Headers
Friends Index
| class | detail::check_result |
|
The check result, which counts the outcome of each check. More... | |
| class | detail::runnable_base |
|
The base of the test tree nodes, which counts the test cases, adds their totals to those of the suite, and counts a test case started on a suite that is not running as a failed check. More... | |
| class | runner |
|
The classes that maintain the counters. More... | |
| class | suite |
|
The suite, which counts an unexpected exception as a failed check. More... | |
| class | test_case |
|
The test case, which counts an unexpected exception as a failed check. More... | |
Public Constructors Index
| counters (const counters &other)=default | |
|
Copy constructor. More... | |
| counters (counters &&other)=default | |
|
Move constructor. More... | |
| counters (void)=default | |
|
Default constructor. More... | |
Public Destructor Index
| ~counters ()=default | |
|
Destructor. More... | |
Public Operators Index
| counters & | operator= (const counters &other)=default |
|
Copy assignment operator. More... | |
| counters & | operator= (counters &&other)=default |
|
Move assignment operator. More... | |
Private Operators Index
| counters & | operator+= (const counters &other) noexcept |
|
Accumulates the totals from another instance into this one. More... | |
Public Member Functions Index
| size_t | executed_checks (void) const noexcept |
|
Returns the total number of checks executed. More... | |
| size_t | executed_test_cases (void) const noexcept |
|
Returns the number of test cases that were executed. More... | |
| size_t | failed_checks (void) const noexcept |
|
Returns the number of checks that failed. More... | |
| size_t | failed_test_cases (void) const noexcept |
|
Returns the number of executed test cases that failed. More... | |
| bool | passed (void) const noexcept |
|
Checks whether all executed checks and test cases were successful. More... | |
| size_t | passed_checks (void) const noexcept |
|
Returns the number of checks that passed. More... | |
| size_t | skipped_test_cases (void) const noexcept |
|
Returns the number of test cases skipped by the filter. More... | |
Private Member Functions Index
| void | increment_executed_test_cases (size_t count=1) noexcept |
|
Increments the executed test cases counter. More... | |
| void | increment_failed_checks (size_t count=1) noexcept |
|
Increments the failed-checks counter. More... | |
| void | increment_failed_test_cases (size_t count=1) noexcept |
|
Increments the failed test cases counter. More... | |
| void | increment_passed_checks (size_t count=1) noexcept |
|
Increments the passed-checks counter. More... | |
| void | increment_skipped_test_cases (size_t count=1) noexcept |
|
Increments the skipped test cases counter. More... | |
Private Member Attributes Index
| size_t | executed_test_cases_ = 0 |
|
Total number of test cases executed. More... | |
| size_t | failed_checks_ = 0 |
|
Total number of failed checks. More... | |
| size_t | failed_test_cases_ = 0 |
|
Total number of executed test cases that failed. More... | |
| size_t | passed_checks_ = 0 |
|
Total number of passed checks. More... | |
| size_t | skipped_test_cases_ = 0 |
|
Total number of test cases skipped by the filter. More... | |
Deprecated Functions Index
| size_t | successful_checks (void) const noexcept |
|
Deprecated name of passed_checks(). More... | |
| size_t | executed_subtests (void) const noexcept |
|
Deprecated name of executed_test_cases(). More... | |
| bool | was_successful (void) const noexcept |
Description
Aggregated check and test case counters for a node in the test tree.
counters records five counters that are maintained throughout a test session:
- the number of checks that passed (passed_checks_),
- the number of checks that failed (failed_checks_),
- the number of test cases that were executed (executed_test_cases_),
- the number of those test cases that failed (failed_test_cases_), and
- the number of test cases skipped by the filter (skipped_test_cases_).
For a test case, the test case counters refer only to its direct nested test cases; for a suite or the runner, they refer to the test cases at all nesting levels.
The runner and every node of the test tree (suite, test_case) own a counters member and accumulate their counts in place. At the end of each suite or session the operator += propagates the child totals up to the parent node, or to the runner.
The tests can read the counters of the runner, of a suite, or of a test case through the totals() accessor. The functions that update the counters are private, and called only by the framework classes, which are friends.
The class is a copyable value type, so that a test can take a snapshot of the counters (counters before = ts.totals ();) and compare it later with the current values. The copy is independent: it is not updated when the original counters change. The nodes that own the live counters are themselves neither copyable nor movable. The runner, the suites, and the test cases return only a const reference, so that the counters of the nodes are read only.
Definition at line 122 of file counters.h.
Friends
detail::check_result
|
The check result, which counts the outcome of each check.
See the friend declaration of runner.
Definition at line 392 of file counters.h.
detail::runnable_base
|
The base of the test tree nodes, which counts the test cases, adds their totals to those of the suite, and counts a test case started on a suite that is not running as a failed check.
See the friend declaration of runner.
Definition at line 402 of file counters.h.
References counters, increment_executed_test_cases, increment_failed_checks, increment_failed_test_cases, increment_passed_checks and increment_skipped_test_cases.
runner
|
The classes that maintain the counters.
The nodes of the test tree and the check result update their counters, and the runner accumulates the totals of the suites; the applications only read them.
Definition at line 366 of file counters.h.
Reference runner.
Referenced by runner.
suite
|
test_case
Public Constructors
counters()
| default |
Copy constructor.
Copies the values of all the counters. The new instance is independent of the original, which may continue to be updated.
- Parameters
-
other The instance to copy.
- Since
6.0.0
Definition at line 144 of file counters.h.
Reference counters.
counters()
| default |
Move constructor.
Equivalent to the copy constructor, since the counters are plain integral values.
- Parameters
-
other The instance to move from.
- Since
6.0.0
Definition at line 157 of file counters.h.
Reference counters.
counters()
| default |
Default constructor.
All counters start at zero, via their default member initialisers.
Definition at line 131 of file counters.h.
Referenced by counters, counters, detail::runnable_base, operator+=, operator= and operator=.
Public Destructor
~counters()
| default |
Destructor.
Trivial; the counters own no resources.
Definition at line 196 of file counters.h.
References executed_checks, executed_subtests, executed_test_cases, failed_checks, failed_test_cases, passed, passed_checks, skipped_test_cases, successful_checks and was_successful.
Public Operators
operator=()
| default |
Copy assignment operator.
Replaces the values of all the counters with those of other.
- Parameters
-
other The instance to copy.
- Returns
Reference to this instance.
- Since
6.0.0
Definition at line 171 of file counters.h.
Reference counters.
operator=()
| default |
Move assignment operator.
Equivalent to the copy assignment operator, since the counters are plain integral values.
- Parameters
-
other The instance to move from.
- Returns
Reference to this instance.
- Since
6.0.0
Definition at line 187 of file counters.h.
Reference counters.
Private Operators
operator+=()
| noexcept |
Accumulates the totals from another instance into this one.
- Parameters
-
other The instance whose totals are to be added.
- Returns
Reference to this instance.
Adds the passed check count, failed check count, executed test case count, failed test case count, and skipped test case count of other to the corresponding members of this instance. Returns a reference to *this to support chaining. When tracing is enabled, the updated totals are output for diagnostic purposes.
Declaration at line 411 of file counters.h, definition at line 71 of file counters.cpp.
References counters, executed_test_cases_, failed_checks_, failed_test_cases_, MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE, passed_checks_ and skipped_test_cases_.
Public Member Functions
executed_checks()
| inline nodiscard noexcept |
Returns the total number of checks executed.
- Parameters
None.
- Returns
The sum of passed and failed checks.
Returns the sum of passed_checks_ and failed_checks_.
Declaration at line 257 of file counters.h, definition at line 143 of file counters-inlines.h.
References failed_checks_ and passed_checks_.
Referenced by ~counters, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite and micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case.
executed_test_cases()
| inline nodiscard noexcept |
Returns the number of test cases that were executed.
- Parameters
None.
- Returns
The cumulative count of executed test cases.
Returns the value of the executed_test_cases_ counter.
Declaration at line 267 of file counters.h, definition at line 153 of file counters-inlines.h.
Reference executed_test_cases_.
Referenced by ~counters, micro_os_plus::micro_test_plus::detail::reporter_human::end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, executed_subtests, micro_os_plus::micro_test_plus::detail::reporter::format_session_totals, micro_os_plus::micro_test_plus::detail::reporter::format_suite_totals and micro_os_plus::micro_test_plus::runner::run_suites.
failed_checks()
| inline nodiscard noexcept |
Returns the number of checks that failed.
- Parameters
None.
- Returns
The cumulative count of failed checks.
Returns the value of the failed_checks_ counter.
Declaration at line 247 of file counters.h, definition at line 133 of file counters-inlines.h.
Reference failed_checks_.
Referenced by ~counters, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, micro_os_plus::micro_test_plus::detail::reporter::format_session_totals, micro_os_plus::micro_test_plus::detail::reporter::format_suite_totals and micro_os_plus::micro_test_plus::detail::reporter::format_test_case_totals.
failed_test_cases()
| inline nodiscard noexcept |
Returns the number of executed test cases that failed.
- Parameters
None.
- Returns
The cumulative count of failed test cases.
Returns the value of the failed_test_cases_ counter.
Declaration at line 303 of file counters.h, definition at line 176 of file counters-inlines.h.
Reference failed_test_cases_.
Referenced by ~counters and micro_os_plus::micro_test_plus::detail::reporter::format_test_case_totals.
passed()
| inline nodiscard noexcept |
Checks whether all executed checks and test cases were successful.
- Parameters
None.
- Return Values
-
true No checks and no test cases failed.
false At least one check or one test case failed.
A node with no checks at all is considered successful, as it did not fail any check. A test case whose own checks all passed is still unsuccessful if one of its nested test cases failed, so that a failure is reported at every level above it, as in node-tap.
Declaration at line 330 of file counters.h, definition at line 199 of file counters-inlines.h.
References failed_checks_ and failed_test_cases_.
Referenced by ~counters, micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create, micro_os_plus::micro_test_plus::detail::reporter_human::end_session, micro_os_plus::micro_test_plus::detail::reporter_human::end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, micro_os_plus::micro_test_plus::detail::reporter_human::end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, micro_os_plus::micro_test_plus::detail::reporter::format_suite_totals, micro_os_plus::micro_test_plus::detail::reporter::format_test_case_totals, micro_os_plus::micro_test_plus::runner::run_suites and was_successful.
passed_checks()
| inline nodiscard noexcept |
Returns the number of checks that passed.
The opposite count is returned by failed_checks(), and their sum by executed_checks().
- Parameters
None.
- Returns
The cumulative count of passed checks.
- Since
6.0.0
Returns the value of the passed_checks_ counter.
Declaration at line 212 of file counters.h, definition at line 110 of file counters-inlines.h.
Reference passed_checks_.
Referenced by ~counters, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, micro_os_plus::micro_test_plus::detail::reporter::format_session_totals, micro_os_plus::micro_test_plus::detail::reporter::format_suite_totals, micro_os_plus::micro_test_plus::detail::reporter::format_test_case_totals and successful_checks.
skipped_test_cases()
| inline nodiscard noexcept |
Returns the number of test cases skipped by the filter.
The skipped test cases are not included in executed_test_cases().
- Parameters
None.
- Returns
The cumulative count of skipped test cases.
- Since
6.0.0
Returns the value of the skipped_test_cases_ counter.
Declaration at line 318 of file counters.h, definition at line 186 of file counters-inlines.h.
Reference skipped_test_cases_.
Referenced by ~counters, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, micro_os_plus::micro_test_plus::detail::reporter::format_session_totals and micro_os_plus::micro_test_plus::detail::reporter::format_suite_totals.
Private Member Functions
increment_executed_test_cases()
| inline noexcept |
Increments the executed test cases counter.
- Parameters
-
count The number of test cases to add (default 1).
- Returns
Nothing.
Adds count to the executed_test_cases_ counter.
Declaration at line 447 of file counters.h, definition at line 80 of file counters-inlines.h.
Reference executed_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create and detail::runnable_base.
increment_failed_checks()
| inline noexcept |
Increments the failed-checks counter.
- Parameters
-
count The number of failed checks to add (default 1).
- Returns
Nothing.
Adds count to the failed_checks_ counter.
Declaration at line 437 of file counters.h, definition at line 70 of file counters-inlines.h.
Reference failed_checks_.
Referenced by micro_os_plus::micro_test_plus::detail::check_result::~check_result, micro_os_plus::micro_test_plus::detail::runnable_base::accepts_test_case, detail::runnable_base, micro_os_plus::micro_test_plus::suite::fail_unexpected_exception, micro_os_plus::micro_test_plus::test_case::fail_unexpected_exception and micro_os_plus::micro_test_plus::runner::reject_call.
increment_failed_test_cases()
| inline noexcept |
Increments the failed test cases counter.
- Parameters
-
count The number of failed test cases to add (default 1).
- Returns
Nothing.
Adds count to the failed_test_cases_ counter.
Declaration at line 457 of file counters.h, definition at line 90 of file counters-inlines.h.
Reference failed_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create and detail::runnable_base.
increment_passed_checks()
| inline noexcept |
Increments the passed-checks counter.
Called for each check that passed; the opposite count is incremented by increment_failed_checks().
- Parameters
-
count The number of passed checks to add (default 1).
- Returns
Nothing.
- Since
6.0.0
Adds count to the passed_checks_ counter.
Declaration at line 427 of file counters.h, definition at line 60 of file counters-inlines.h.
Reference passed_checks_.
Referenced by micro_os_plus::micro_test_plus::detail::check_result::~check_result and detail::runnable_base.
increment_skipped_test_cases()
| inline noexcept |
Increments the skipped test cases counter.
- Parameters
-
count The number of skipped test cases to add (default 1).
- Returns
Nothing.
- Since
6.0.0
Adds count to the skipped_test_cases_ counter.
Declaration at line 469 of file counters.h, definition at line 100 of file counters-inlines.h.
Reference skipped_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create and detail::runnable_base.
Private Member Attributes
executed_test_cases_
|
Total number of test cases executed.
Incremented by increment_executed_test_cases() and by operator+=.
Definition at line 494 of file counters.h.
Referenced by executed_test_cases, increment_executed_test_cases and operator+=.
failed_checks_
|
Total number of failed checks.
Incremented by increment_failed_checks() and by operator+=.
Definition at line 485 of file counters.h.
Referenced by executed_checks, failed_checks, increment_failed_checks, operator+= and passed.
failed_test_cases_
|
Total number of executed test cases that failed.
Incremented by increment_failed_test_cases(), when a test case ends with a failed check or a failed nested test case, and by operator+=. A test case fails when any of its nested test cases fails, as in node-tap, although the checks of the nested test cases are not counted in its check counters.
Definition at line 506 of file counters.h.
Referenced by failed_test_cases, increment_failed_test_cases, operator+= and passed.
passed_checks_
|
Total number of passed checks.
Incremented by increment_passed_checks() and by operator+=.
Definition at line 477 of file counters.h.
Referenced by executed_checks, increment_passed_checks, operator+= and passed_checks.
skipped_test_cases_
|
Total number of test cases skipped by the filter.
Incremented by increment_skipped_test_cases(), when the name of a test case, or of its suite, does not match the filter pattern of its level, and by operator+=.
Definition at line 516 of file counters.h.
Referenced by increment_skipped_test_cases, operator+= and skipped_test_cases.
Deprecated Functions
executed_subtests()
| inline nodiscard noexcept |
Deprecated name of executed_test_cases().
Calls executed_test_cases(). The old name referred to the subtest class, which is now test_case.
- Parameters
None.
- Returns
The value returned by executed_test_cases().
- Deprecated
-
use executed_test_cases() (since 6.0.0)
Forwards to executed_test_cases().
Declaration at line 288 of file counters.h, definition at line 165 of file counters-inlines.h.
Reference executed_test_cases.
Referenced by ~counters.
successful_checks()
| inline nodiscard noexcept |
Deprecated name of passed_checks().
Calls passed_checks(). The old name called the checks "successful", while the reporters print them as "passed".
- Parameters
None.
- Returns
The value returned by passed_checks().
- Deprecated
-
use passed_checks() (since 6.0.0)
Forwards to passed_checks().
Declaration at line 232 of file counters.h, definition at line 122 of file counters-inlines.h.
Reference passed_checks.
Referenced by ~counters.
was_successful()
| inline nodiscard noexcept |
Deprecated name of passed().
Calls passed(). The new name matches the word used by the reports, and by passed_checks().
- Parameters
None.
- Returns
The value returned by passed().
- Deprecated
-
use passed() (since 6.0.0)
Forwards to passed().
Declaration at line 350 of file counters.h, definition at line 211 of file counters-inlines.h.
Reference passed.
Referenced by ~counters.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.