|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Aggregated check and test case counters for a node in the test tree. More...
#include "micro-os-plus/micro-test-plus.h"
Public Member Functions | |
| counters (const counters &other)=default | |
| Copy constructor. | |
| counters (counters &&other)=default | |
| Move constructor. | |
| counters (void)=default | |
| Default constructor. | |
| ~counters ()=default | |
| Destructor. | |
| size_t | executed_checks (void) const noexcept |
| Returns the total number of checks executed. | |
| size_t | executed_test_cases (void) const noexcept |
| Returns the number of test cases that were executed. | |
| size_t | failed_checks (void) const noexcept |
| Returns the number of checks that failed. | |
| size_t | failed_test_cases (void) const noexcept |
| Returns the number of executed test cases that failed. | |
| counters & | operator= (const counters &other)=default |
| Copy assignment operator. | |
| counters & | operator= (counters &&other)=default |
| Move assignment operator. | |
| bool | passed (void) const noexcept |
| Checks whether all executed checks and test cases were successful. | |
| size_t | passed_checks (void) const noexcept |
| Returns the number of checks that passed. | |
| size_t | skipped_test_cases (void) const noexcept |
| Returns the number of test cases skipped by the filter. | |
Deprecated Functions | |
| size_t | successful_checks (void) const noexcept |
| Deprecated name of passed_checks(). | |
| size_t | executed_subtests (void) const noexcept |
| Deprecated name of executed_test_cases(). | |
| bool | was_successful (void) const noexcept |
| Deprecated name of passed(). | |
Private Member Functions | |
| void | increment_executed_test_cases (size_t count=1) noexcept |
| Increments the executed test cases counter. | |
| void | increment_failed_checks (size_t count=1) noexcept |
| Increments the failed-checks counter. | |
| void | increment_failed_test_cases (size_t count=1) noexcept |
| Increments the failed test cases counter. | |
| void | increment_passed_checks (size_t count=1) noexcept |
| Increments the passed-checks counter. | |
| void | increment_skipped_test_cases (size_t count=1) noexcept |
| Increments the skipped test cases counter. | |
| counters & | operator+= (const counters &other) noexcept |
| Accumulates the totals from another instance into this one. | |
Private Attributes | |
| size_t | executed_test_cases_ = 0 |
| Total number of test cases executed. | |
| size_t | failed_checks_ = 0 |
| Total number of failed checks. | |
| size_t | failed_test_cases_ = 0 |
| Total number of executed test cases that failed. | |
| size_t | passed_checks_ = 0 |
| Total number of passed checks. | |
| size_t | skipped_test_cases_ = 0 |
| Total number of test cases skipped by the filter. | |
Friends | |
| class | detail::check_result |
| The check result, which counts the outcome of each check. | |
| 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. | |
| class | runner |
| The classes that maintain the counters. | |
| class | suite |
| The suite, which counts an unexpected exception as a failed check. | |
| class | test_case |
| The test case, which counts an unexpected exception as a failed check. | |
counters records five counters that are maintained throughout a test session:
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.
|
default |
All counters start at zero, via their default member initialisers.
Referenced by counters(), counters(), detail::runnable_base, operator+=(), operator=(), and operator=().
|
default |
Copies the values of all the counters. The new instance is independent of the original, which may continue to be updated.
| other | The instance to copy. |
References counters().
|
default |
Equivalent to the copy constructor, since the counters are plain integral values.
| other | The instance to move from. |
References counters().
|
default |
Trivial; the counters own no resources.
References executed_checks(), executed_subtests(), executed_test_cases(), failed_checks(), failed_test_cases(), passed(), passed_checks(), skipped_test_cases(), successful_checks(), and was_successful().
|
inlinenodiscardnoexcept |
Returns the sum of passed_checks_ and failed_checks_.
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().
|
inlinenodiscardnoexcept |
Calls executed_test_cases(). The old name referred to the subtest class, which is now test_case.
Forwards to executed_test_cases().
Definition at line 165 of file counters-inlines.h.
References executed_test_cases().
Referenced by ~counters().
|
inlinenodiscardnoexcept |
Returns the value of the executed_test_cases_ counter.
Definition at line 153 of file counters-inlines.h.
References 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().
|
inlinenodiscardnoexcept |
Returns the value of the failed_checks_ counter.
Definition at line 133 of file counters-inlines.h.
References 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().
|
inlinenodiscardnoexcept |
Returns the value of the failed_test_cases_ counter.
Definition at line 176 of file counters-inlines.h.
References failed_test_cases_.
Referenced by ~counters(), and micro_os_plus::micro_test_plus::detail::reporter::format_test_case_totals().
|
inlineprivatenoexcept |
| count | The number of test cases to add (default 1). |
Adds count to the executed_test_cases_ counter.
Definition at line 80 of file counters-inlines.h.
References executed_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create(), and detail::runnable_base.
|
inlineprivatenoexcept |
| count | The number of failed checks to add (default 1). |
Adds count to the failed_checks_ counter.
Definition at line 70 of file counters-inlines.h.
References 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().
|
inlineprivatenoexcept |
| count | The number of failed test cases to add (default 1). |
Adds count to the failed_test_cases_ counter.
Definition at line 90 of file counters-inlines.h.
References failed_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create(), and detail::runnable_base.
|
inlineprivatenoexcept |
Called for each check that passed; the opposite count is incremented by increment_failed_checks().
| count | The number of passed checks to add (default 1). |
Adds count to the passed_checks_ counter.
Definition at line 60 of file counters-inlines.h.
References passed_checks_.
Referenced by micro_os_plus::micro_test_plus::detail::check_result::~check_result(), and detail::runnable_base.
|
inlineprivatenoexcept |
| count | The number of skipped test cases to add (default 1). |
Adds count to the skipped_test_cases_ counter.
Definition at line 100 of file counters-inlines.h.
References skipped_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_test_case_create(), and detail::runnable_base.
|
privatenoexcept |
| other | The instance whose totals are to be added. |
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.
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_.
Replaces the values of all the counters with those of other.
| other | The instance to copy. |
References counters().
Equivalent to the copy assignment operator, since the counters are plain integral values.
| other | The instance to move from. |
References counters().
|
inlinenodiscardnoexcept |
| 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.
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().
|
inlinenodiscardnoexcept |
The opposite count is returned by failed_checks(), and their sum by executed_checks().
Returns the value of the passed_checks_ counter.
Definition at line 110 of file counters-inlines.h.
References 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().
|
inlinenodiscardnoexcept |
The skipped test cases are not included in executed_test_cases().
Returns the value of the skipped_test_cases_ counter.
Definition at line 186 of file counters-inlines.h.
References 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().
|
inlinenodiscardnoexcept |
Calls passed_checks(). The old name called the checks "successful", while the reporters print them as "passed".
Forwards to passed_checks().
Definition at line 122 of file counters-inlines.h.
References passed_checks().
Referenced by ~counters().
|
inlinenodiscardnoexcept |
Calls passed(). The new name matches the word used by the reports, and by passed_checks().
Forwards to passed().
Definition at line 211 of file counters-inlines.h.
References passed().
Referenced by ~counters().
|
friend |
See the friend declaration of runner.
Definition at line 392 of file counters.h.
|
friend |
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().
|
friend |
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.
References runner.
Referenced by runner.
|
friend |
See the friend declaration of runner.
Definition at line 375 of file counters.h.
References suite.
Referenced by suite.
|
friend |
See the friend declaration of runner.
Definition at line 384 of file counters.h.
References test_case.
Referenced by test_case.
|
private |
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+=().
|
private |
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().
|
private |
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().
|
private |
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().
|
private |
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().