reporter_human Class
Human (standard output) implementation of reporter. More...
Declaration
Included Headers
Base class
| class | reporter |
|
Abstract base class for the reporters that display test results, including operand values for failures. More... | |
Public Constructors Index
| reporter_human (const reporter_human &)=delete | |
|
Deleted copy constructor to prevent copying. More... | |
| reporter_human (const runner_options &opts) | |
|
Constructor for the reporter_human class. More... | |
| reporter_human (reporter_human &&)=delete | |
|
Deleted move constructor to prevent moving. More... | |
Public Destructor Index
| ~reporter_human () override | |
|
Destructor for the reporter_human class. More... | |
Public Operators Index
| reporter & | operator<< (bool v) |
|
Output operator for boolean values. More... | |
| reporter & | operator<< (char c) |
|
Output operator for a single character. More... | |
| reporter & | operator<< (const char *s) |
|
Output operator for a constant character string. More... | |
| reporter & | operator<< (indentation m) |
|
Output operator for the indentation manipulator. More... | |
| reporter & | operator<< (reporter &(*func)(reporter &)) |
|
Output operator for stream manipulators, such as endl. More... | |
| reporter & | operator<< (std::nullptr_t) |
|
Output operator for nullptr. More... | |
| reporter & | operator<< (std::string_view sv) |
|
Output operator for std::string_view. More... | |
template <typename T> | |
| reporter & | operator<< (T *v) |
|
Output operator to display any pointer. More... | |
template <class T> | |
| reporter & | operator<< (T v) |
|
Output operator for arithmetic types. More... | |
| reporter_human & | operator= (const reporter_human &)=delete |
|
Deleted copy assignment operator to prevent copying. More... | |
| reporter_human & | operator= (reporter_human &&)=delete |
|
Deleted move assignment operator to prevent moving. More... | |
Public Member Functions Index
| void | abort_session (const reflection::source_location &location, bool is_requirement) override |
|
Reports the abort of the test execution. More... | |
| void | begin_session (const runner &runner) override |
|
Marks the beginning of a test session. More... | |
| void | begin_suite (const suite &suite) override |
|
Marks the beginning of a test suite. More... | |
| void | begin_test_case (const test_case &test_case) override |
|
Marks the beginning of a test case. More... | |
| const char * | comment_prefix (void) const noexcept override |
|
Returns an empty comment prefix string. More... | |
| void | end_line (void) |
|
Appends a line ending to the internal output buffer. More... | |
| void | end_session (const runner &runner) override |
|
Marks the end of a test session. More... | |
| void | end_suite (const suite &suite) override |
|
Marks the end of a test suite. More... | |
| void | end_test_case (const test_case &test_case) override |
|
Marks the end of a test case. More... | |
| const char * | error_prefix (void) const noexcept |
|
Returns the prefix of the lines that report an error. More... | |
| void | fail (const failure_info &failure, const std::string &expression, const test_case &test_case) |
|
Reports a failed condition. More... | |
| void | fail_suite (const std::string &message, const suite &suite) override |
|
Reports a failure of a test suite outside its test cases. More... | |
| void | flush_streams (void) |
|
Flushes the standard output stream and the output file. More... | |
| bool | has_output_file_error (void) const noexcept |
|
Returns whether the output file could not be opened. More... | |
| void | pass (const std::string &message, const std::string &expression, const test_case &test_case) |
|
Reports a passed condition. More... | |
| void | pass_without_text (const test_case &test_case) override |
|
Ignores a passed check whose text is not written. More... | |
| void | skip_suite (const suite &suite) override |
|
Reports a test suite skipped by the filter. More... | |
| void | skip_test_case (const test_case &test_case) override |
|
Reports a test case skipped by the filter. More... | |
| bool | writes_passed_checks (void) const noexcept |
|
Returns whether the passed checks are written anywhere. More... | |
Protected Member Functions Index
| void | announce_output_file (void) |
|
Tells the console where the output file was written. More... | |
| void | clear_buffer (void) |
|
Clears the output buffer. More... | |
| void | commit_outer_results (void) |
|
Writes the results of the outer test case, if any, before a nested test case begins or is skipped. More... | |
| std::string_view | console_lines (bool failed) const noexcept |
|
Returns the buffered lines that the console displays when a test case or a suite ends, or when its results are committed. More... | |
| void | display_open_test_cases (bool include_last) |
|
Displays the headings not yet displayed, of the open test cases. More... | |
| void | enter_suite (const suite &suite, bool displayed) |
|
Notes the suite that begins, for the headings displayed later. More... | |
| void | mark_failure (size_t begin) |
|
Records that the lines appended to the buffer from a given position are a failure. More... | |
| output_route | route (record_kind kind) const noexcept |
|
Tells where a kind of record is written. More... | |
| void | write_buffer_to_file (void) |
|
Writes the current buffered content to the output file. More... | |
| void | write_console (const char *format,...) |
|
Writes formatted text to the console. More... | |
| void | write_console_text (std::string_view text) |
|
Writes a text to the console, unchanged. More... | |
| void | write_file (const char *format,...) |
|
Writes formatted text to the output file. More... | |
| void | write_info (const std::vector< std::string > &arguments) |
|
Writes the informational (non-result) lines to the console and to the output file. More... | |
| void | write_line (bool to_console, const char *format,...) |
|
Writes formatted lines to the output file and, when requested, to the console. More... | |
Private Member Functions Index
| void | commit_buffer (void) override |
|
Writes the results buffered for the outer test case before a nested test case begins. More... | |
| void | display_open_heading (const open_test_case &open, bool is_first) override |
|
Writes the heading of an open test case. More... | |
| void | display_open_names (bool include_last) |
|
Displays the headings not yet displayed, of the suite and of the open test cases. More... | |
| void | output_fail_prefix (const std::string &message, const bool has_expression, const reflection::source_location &location, const test_case &test_case) override |
|
Outputs the prefix for a failing condition. More... | |
| void | output_fail_suffix (const reflection::source_location &location, check_kind kind, const test_case &test_case) override |
|
Outputs the suffix for a failing condition. More... | |
| void | output_pass_prefix (const std::string &message, const test_case &test_case) override |
|
Outputs the prefix for a passing condition. More... | |
| void | output_pass_suffix (const test_case &test_case) override |
|
Outputs the suffix for a passing condition. More... | |
Protected Member Attributes Index
| bool | add_empty_line_ { true } |
|
Whether to write an empty line before the next console output. More... | |
| std::string | buffer_ {} |
|
Output accumulation buffer. More... | |
| bool | buffer_has_failures_ { false } |
|
Whether the output buffer contains a failed check. More... | |
| colours | colours_ {} |
|
ANSI colour codes for output formatting. More... | |
| const suite * | current_suite_ { nullptr } |
|
The suite that has begun and not yet ended. More... | |
| expression_formatter | expression_ { colours_ } |
|
Expression formatter for pass and fail reporting. More... | |
| std::string | failures_ {} |
|
The lines of the failed checks, for the quiet verbosity. More... | |
| bool | has_output_file_error_ { false } |
|
Whether the output file could not be opened. More... | |
| std::vector< open_test_case > | open_test_cases_ {} |
|
The test cases that have begun and not yet ended, outermost first. More... | |
| FILE * | output_file_ { nullptr } |
|
Optional output file, receiving a copy of the test report. More... | |
| std::string | output_file_path_ {} |
|
Path of the optional output file. More... | |
| bool | suite_displayed_ { false } |
|
Whether the heading of the current suite was displayed on the console. More... | |
| const micro_test_plus::verbosity | verbosity_ |
|
The verbosity level for test reporting. More... | |
Protected Static Functions Index
| static void | format_elapsed_time (const stopwatch &stopwatch, char(&message)[elapsed_time_size_]) |
|
Formats the elapsed time of a suite or of the session. More... | |
| static void | format_session_totals (const runner &runner, char(&message)[totals_size_]) |
|
Formats the totals of the test session. More... | |
| static void | format_suite_totals (const suite &suite, char(&message)[totals_size_]) |
|
Formats the totals of a suite. More... | |
| static void | format_test_case_totals (const test_case &test_case, char(&message)[totals_size_]) |
|
Formats the totals of a test case. More... | |
Protected Static Attributes Index
| static constexpr size_t | elapsed_time_size_ = 40 |
|
Size of the array that receives the elapsed time text. More... | |
| static constexpr size_t | indent_size_ = 4 |
|
Number of spaces per nesting level. More... | |
| static constexpr size_t | totals_size_ = 94 + 6 * (std::numeric_limits<size_t>::digits10 + 1) |
|
Size of the array that receives the totals text. More... | |
Deprecated Functions Index
| micro_test_plus::verbosity | verbosity (void) const noexcept |
|
Deprecated access to the verbosity level. More... | |
Description
Human (standard output) implementation of reporter.
reporter_human provides a concrete implementation of the reporter abstract interface, formatting and presenting test results in a human-readable form. It accumulates output in an internal string buffer and writes it to the standard output stream, supporting colour-coded diagnostics (when the output is a terminal, or when forced with --colour) and multiple verbosity levels.
The reporter is intended for the people who read the console output. The optional output file receives the complete report, whatever the verbosity of the console, and never receives colours, as with the TAP reporter.
The reporter is created by the runner, as selected by the --reporter command-line option, or by runner_options::selected_reporter. A different output format requires a new class derived from reporter, and an extension of the runner to create it.
All members are defined within the micro_os_plus::micro_test_plus::detail namespace, since the reporters are internal to the framework.
Definition at line 101 of file reporter-human.h.
Public Constructors
reporter_human()
| delete |
Deleted copy constructor to prevent copying.
The reporter owns the output buffer and the output file, which must not be shared.
Definition at line 119 of file reporter-human.h.
Reference reporter_human.
reporter_human()
| explicit |
Constructor for the reporter_human class.
- Parameters
-
opts The session options, passed to runner::initialise() or parsed by it from the command line.
Delegates construction to the reporter base class with the supplied options. Colour output is enabled, by selecting the red/green colour scheme, when opts.colour is colour_mode::always, or when it is colour_mode::automatic and, on POSIX platforms, stdout is connected to a terminal (isatty()). If tracing is enabled, the function signature is output for diagnostic purposes.
Declaration at line 110 of file reporter-human.h, definition at line 80 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::always, micro_os_plus::micro_test_plus::automatic, micro_os_plus::micro_test_plus::runner_options::colour, micro_os_plus::micro_test_plus::detail::reporter::colours_ and micro_os_plus::micro_test_plus::detail::colours_red_green.
Referenced by reporter_human, reporter_human, operator= and operator=.
reporter_human()
| delete |
Deleted move constructor to prevent moving.
The reporter is owned by the runner, through a pointer, and is never relocated.
Definition at line 128 of file reporter-human.h.
Reference reporter_human.
Public Destructor
~reporter_human()
|
Destructor for the reporter_human class.
The output file, if any, is closed by the base class destructor.
No resources are owned directly by reporter_human; the destructor performs no explicit clean-up. If tracing is enabled, the function signature is output for diagnostic purposes.
Declaration at line 158 of file reporter-human.h, definition at line 108 of file reporter-human.cpp.
Public Operators
operator<<()
|
Output operator for boolean values.
- Parameters
-
v The boolean value to output.
- Returns
Reference to the current reporter instance.
This operator overload appends "true" or "false" to the internal output buffer of the reporter, as the expression formatter does. Being a non-template function, it is selected for bool values instead of the arithmetic template, which would format them as numbers.
Declaration at line 359 of file reporter.h, definition at line 726 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator<<()
|
Output operator for a single character.
- Parameters
-
c The character to output.
- Returns
Reference to the current reporter instance.
This operator overload appends the specified character to the internal output buffer of the reporter.
Declaration at line 336 of file reporter.h, definition at line 689 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator<<()
|
Output operator for a constant character string.
Also selected for the non-const char pointers and arrays, which the pointer template does not accept. A null pointer is output as "nullptr".
- Parameters
-
s The string to output, or a null pointer.
- Returns
Reference to the current reporter instance.
This operator overload appends the contents of the provided C-style string to the internal output buffer of the reporter, or "nullptr" for a null pointer, as the expression formatter does; the char* values also reach this overload, and std::string::append() must not be called with a null pointer.
Declaration at line 350 of file reporter.h, definition at line 704 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator<<()
|
Output operator for the indentation manipulator.
Appends indent_size_ spaces for each indentation level.
- Parameters
-
m The indentation manipulator produced by indent(n).
- Returns
Reference to the current reporter instance.
This operator overload appends spaces to the internal output buffer, indent_size_ for each of the m.level indentation levels, allowing *this << indent(n) << "text" chaining in both reporters.
Declaration at line 418 of file reporter.h, definition at line 665 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::reporter::buffer_, micro_os_plus::micro_test_plus::detail::reporter::indent_size_ and micro_os_plus::micro_test_plus::detail::indentation::level.
operator<<()
|
Output operator for stream manipulators, such as endl.
- Parameters
-
func Function pointer to the stream manipulator.
- Returns
Reference to the current reporter instance.
This operator overload enables manipulators, such as endl, to be used with the reporter stream in a manner similar to standard C++ streams. When a manipulator function is passed, it is invoked with the current reporter instance.
Declaration at line 406 of file reporter.h, definition at line 651 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::reporter.
operator<<()
|
Output operator for nullptr.
- Returns
Reference to the current reporter instance.
This operator overload appends the string "nullptr" to the internal output buffer of the reporter, as the expression formatter does.
Declaration at line 367 of file reporter.h, definition at line 738 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator<<()
|
Output operator for std::string_view.
- Parameters
-
sv The string view to output.
- Returns
Reference to the current reporter instance.
This operator overload appends the contents of the provided std::string_view to the internal output buffer of the reporter.
Declaration at line 327 of file reporter.h, definition at line 677 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::reporter and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator<<()
|
Output operator to display any pointer.
The char pointers are excluded, so that they are output as strings by the const char* overload, as the const char pointers are.
- Template Parameters
-
T The type pointed to, other than char.
- Parameters
-
v The pointer value to output.
- Returns
Reference to the current reporter instance.
The address is formatted by the detail::append_pointer() helper, shared with the detail::expression_formatter, so that the pointers are displayed identically in the expressions and in the messages.
Declaration at line 397 of file reporter.h, definition at line 80 of file reporter-inlines.h.
References micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::append_pointer and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator<<()
|
Output operator for arithmetic types.
- Template Parameters
-
T The arithmetic type.
- Parameters
-
v The value to output.
- Returns
Reference to the current reporter instance.
This template operator overload allows the reporter to output values of any arithmetic type (integral or floating-point) in a consistent and readable format. The value is formatted using the detail::append_number() helper, without a type suffix (unlike the detail::expression_formatter operators, which add one).
Declaration at line 379 of file reporter.h, definition at line 97 of file reporter-inlines.h.
References micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::append_number and micro_os_plus::micro_test_plus::detail::reporter::buffer_.
operator=()
| delete |
Deleted copy assignment operator to prevent copying.
The reporter owns the output buffer and the output file, which must not be shared.
Definition at line 138 of file reporter-human.h.
Reference reporter_human.
operator=()
| delete |
Deleted move assignment operator to prevent moving.
The reporter is owned by the runner, through a pointer, and is never relocated.
Definition at line 149 of file reporter-human.h.
References reporter_human, abort_session, begin_session, begin_suite, begin_test_case, comment_prefix, commit_buffer, display_open_heading, display_open_names, end_session, end_suite, end_test_case, fail_suite, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, output_fail_prefix, output_fail_suffix, output_pass_prefix, output_pass_suffix, pass_without_text, skip_suite and skip_test_case.
Public Member Functions
abort_session()
| virtual |
Reports the abort of the test execution.
Displays the names of the open test cases not yet displayed, followed by the buffered check results, and a final ✗ Test execution aborted at <file>:<line> line, in place of the totals.
- Parameters
-
location The source location of the failed requirement, or of the runner::abort() call.
is_requirement true if the abort is caused by a failed requirement.
- Returns
Nothing.
Since end_test_case() is not called for the running test cases, this member function writes the buffered results in its place; after a failed requirement, they end with it. As in end_test_case(), they are always written to the output file.
Unless the verbosity is silent, the headings of the suite and of the open test cases that were not displayed yet (all of them, with normal or quiet verbosity) are written to stdout, followed by the buffered results, so that a failure is not attributed to the previous test case. With quiet verbosity, which otherwise displays only the failures and the summary, the lines of the failed checks are displayed, since the summary is never reached.
In place of the summary, a ✗ Test execution aborted at <file>:<line> line is then written, as the summary is, to the output file and, unless the verbosity is silent, to stdout. After a failed requirement, the location is the same as in the failure line, which is already marked - test execution aborted; for an explicit call of runner::abort(), it is the only report of the abort.
The buffer is then cleared, so that its results are not written again, should the abort handler throw an exception that the application catches.
Declaration at line 297 of file reporter-human.h, definition at line 751 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::abort, micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::announce_output_file, micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::console_lines, micro_os_plus::micro_test_plus::detail::reporter::current_suite_, display_open_names, micro_os_plus::micro_test_plus::utility::extract_file_name, micro_os_plus::micro_test_plus::detail::colours::fail, micro_os_plus::micro_test_plus::reflection::source_location::file_name, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::reflection::source_location::line, micro_os_plus::micro_test_plus::detail::colours::none, micro_os_plus::micro_test_plus::detail::reporter::open_test_cases_, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::reporter::suite_displayed_, micro_os_plus::micro_test_plus::detail::reporter::write_buffer_to_file, micro_os_plus::micro_test_plus::detail::reporter::write_console, micro_os_plus::micro_test_plus::detail::reporter::write_console_text and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
begin_session()
| virtual |
Marks the beginning of a test session.
- Parameters
-
runner Reference to the test runner.
- Returns
Nothing.
If verbosity is not silent, a blank line is printed to stdout before the build-information block emitted by write_info(). A fixed "µTest++ human-readable report" heading is then written to the output file (if open) and, unless verbosity is silent, to stdout. The add_empty_line_ flag is set so that subsequent suite output is visually separated.
Declaration at line 170 of file reporter-human.h, definition at line 127 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::runner_options::arguments, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner, micro_os_plus::micro_test_plus::runner::options_, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::total, micro_os_plus::micro_test_plus::detail::reporter::write_console, micro_os_plus::micro_test_plus::detail::reporter::write_info and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
begin_suite()
| virtual |
Marks the beginning of a test suite.
- Parameters
-
suite Reference to the suite.
- Returns
Nothing.
This member function writes a "• <name>" line, marking the beginning of the test suite, to the output file (if open) and, with normal or verbose verbosity, to stdout, preceded on stdout by an empty line when add_empty_line_ is set. For silent or quiet verbosity levels, nothing is written to stdout; with quiet verbosity, the heading is displayed later, if the suite has a failure (see display_open_names()).
Declaration at line 190 of file reporter-human.h, definition at line 208 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::enter_suite, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::suite_heading, micro_os_plus::micro_test_plus::detail::reporter::write_console and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
begin_test_case()
| virtual |
Marks the beginning of a test case.
- Parameters
-
test_case Reference to the test case.
- Returns
Nothing.
This member function marks the beginning of a test case. For a nested test case, the results of the checks already performed by the outer test case, if any, are written first (see commit_outer_results()), so that the output follows the execution order.
A "• <name>" line, indented according to the nesting depth, is written to the output file (if open) and, with verbose verbosity, to stdout, preceded by an empty line when add_empty_line_ is set. With the other verbosity levels, the heading is displayed later, only if something is displayed under it (see display_open_names()).
Declaration at line 239 of file reporter-human.h, definition at line 398 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::commit_outer_results, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::detail::reporter::indent_size_, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::test_case::nesting_depth, micro_os_plus::micro_test_plus::detail::reporter::open_test_cases_, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::test_case_heading, micro_os_plus::micro_test_plus::detail::reporter::write_console and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
comment_prefix()
| noexcept virtual |
Returns an empty comment prefix string.
- Parameters
None.
- Returns
An empty string, as the human-readable format does not use a comment prefix.
Returns an empty string. The human-readable reporter does not prefix comment lines; the write_info() output appears as plain text.
Declaration at line 309 of file reporter-human.h, definition at line 538 of file reporter-human.cpp.
Referenced by operator=.
end_line()
|
Appends a line ending to the internal output buffer.
Nothing is written to the console or to the output file; the buffer is written by the concrete reporters, at the end of each test case or suite.
- Parameters
None.
- Returns
Nothing.
This member function appends a newline character to the internal output buffer of the reporter. The buffer itself is written later, by the concrete reporters, at the end of each test case or suite, which then also flush the streams.
Declaration at line 437 of file reporter.h, definition at line 232 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::buffer_.
Referenced by micro_os_plus::micro_test_plus::detail::endl and micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner.
end_session()
| virtual |
Marks the end of a test session.
- Parameters
-
runner Reference to the test runner.
- Returns
Nothing.
Prints a summary line to the output file (if open) and, unless verbosity is silent, to stdout, showing the total number of successful checks, failed checks, executed test cases, and test suites, each count followed by the number skipped by the filter (only when not zero), together with the elapsed time when timing data is available. The line is prefixed with a green ✓ tick on success or a red ✗ cross on failure, using ANSI colour codes when colour output is enabled.
Declaration at line 180 of file reporter-human.h, definition at line 161 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::announce_output_file, micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::elapsed_time_size_, micro_os_plus::micro_test_plus::detail::colours::fail, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::format_elapsed_time, micro_os_plus::micro_test_plus::detail::reporter::format_session_totals, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner, micro_os_plus::micro_test_plus::detail::colours::none, micro_os_plus::micro_test_plus::detail::colours::pass, micro_os_plus::micro_test_plus::counters::passed, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::runner::stopwatch_, micro_os_plus::micro_test_plus::detail::total, micro_os_plus::micro_test_plus::runner::totals, micro_os_plus::micro_test_plus::detail::reporter::totals_size_, micro_os_plus::micro_test_plus::detail::reporter::write_console and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
end_suite()
| virtual |
Marks the end of a test suite.
- Parameters
-
suite Reference to the test suite.
- Returns
Nothing.
This member function summarises the results of the test suite, with appropriate formatting and colour coding. An empty line is first added on stdout if the suite executed any test cases.
For suites without failed checks, a "✓ <name> - passed" line is written, including the number of checks and test cases; the buffered check results are written to stdout only with verbose verbosity. Otherwise, a "✗ <name> - FAILED" line is shown, detailing the number of successful and failed checks and the number of test cases, preceded by the buffered check results. The elapsed time is appended when available.
The buffered check results and the result line are always written to the output file. For silent or quiet verbosity levels, the result line is not written to stdout; with quiet verbosity, only the failure of the suite body, if any, is.
Finally, the streams are flushed and the buffer is cleared.
Declaration at line 200 of file reporter-human.h, definition at line 255 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::console_lines, micro_os_plus::micro_test_plus::detail::reporter::current_suite_, display_open_names, micro_os_plus::micro_test_plus::detail::reporter::elapsed_time_size_, micro_os_plus::micro_test_plus::counters::executed_test_cases, micro_os_plus::micro_test_plus::detail::colours::fail, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::format_elapsed_time, micro_os_plus::micro_test_plus::detail::reporter::format_suite_totals, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::detail::colours::none, micro_os_plus::micro_test_plus::detail::colours::pass, micro_os_plus::micro_test_plus::counters::passed, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::suite::stopwatch_, micro_os_plus::micro_test_plus::detail::suite_result, micro_os_plus::micro_test_plus::detail::runnable_base::totals, micro_os_plus::micro_test_plus::detail::reporter::totals_size_, micro_os_plus::micro_test_plus::detail::reporter::write_buffer_to_file, micro_os_plus::micro_test_plus::detail::reporter::write_console, micro_os_plus::micro_test_plus::detail::reporter::write_console_text and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
end_test_case()
| virtual |
Marks the end of a test case.
- Parameters
-
test_case Reference to the test case.
- Returns
Nothing.
This member function summarises the outcome of the test case, with appropriate formatting and colour coding.
For passing test cases, a "✓ <name> - passed" line is written with the number of checks; the buffered check results are written to stdout only with verbose verbosity. With normal verbosity, the names of the outer test cases are displayed first, if not displayed yet, so that the line of a nested test case is not left without its parent. A test case fails when one of its checks or one of its nested test cases failed. For failing test cases, the buffered check results are shown (preceded, with normal or quiet verbosity, by the names of the test case and of the outer test cases, if not already displayed), followed, with normal or verbose verbosity, by a "✗ <name> - FAILED" line with the number of successful and failed checks, and of the failed nested test cases, when not zero. With quiet verbosity, only the lines of the failed checks are shown.
The buffered check results and the result line are always written to the output file.
Finally, the streams are flushed and the buffer is cleared.
Declaration at line 249 of file reporter-human.h, definition at line 452 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::console_lines, display_open_names, micro_os_plus::micro_test_plus::detail::colours::fail, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::format_test_case_totals, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::detail::reporter::indent_size_, MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::test_case::nesting_depth, micro_os_plus::micro_test_plus::detail::colours::none, micro_os_plus::micro_test_plus::detail::reporter::open_test_cases_, micro_os_plus::micro_test_plus::detail::colours::pass, micro_os_plus::micro_test_plus::counters::passed, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::test_case_heading, micro_os_plus::micro_test_plus::detail::test_case_result, micro_os_plus::micro_test_plus::detail::runnable_base::totals, micro_os_plus::micro_test_plus::detail::reporter::totals_size_, micro_os_plus::micro_test_plus::detail::reporter::write_buffer_to_file, micro_os_plus::micro_test_plus::detail::reporter::write_console, micro_os_plus::micro_test_plus::detail::reporter::write_console_text and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
error_prefix()
| noexcept virtual |
Returns the prefix of the lines that report an error.
Used by the runner to write the command-line errors on the console when it refuses to run the tests, so that they are valid in the output format (for TAP, a Bail out! line). The default is "error: ", as the messages written on stderr.
- Parameters
None.
- Returns
A null-terminated prefix string.
Returns "error: ", as the messages written on stderr; the TAP reporter overrides it with its bail-out marker.
Declaration at line 775 of file reporter.h, definition at line 267 of file reporter.cpp.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::comment_prefix.
fail()
|
Reports a failed condition.
- Parameters
-
failure The failure details: the kind of the check, the message to display, whether the expression text is displayed, and the source location of the failure.
expression The string representation of the expression.
test_case The test case that owns this check.
- Returns
Nothing.
Outputs a fail prefix (which includes the message and the source location), followed, when failure.has_expression is true, by the pre-formatted expression string, and a fail suffix.
Declaration at line 546 of file reporter.h, definition at line 771 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_, micro_os_plus::micro_test_plus::detail::failure_info::has_expression, micro_os_plus::micro_test_plus::detail::failure_info::kind, micro_os_plus::micro_test_plus::detail::failure_info::location, micro_os_plus::micro_test_plus::detail::reporter::mark_failure, micro_os_plus::micro_test_plus::detail::failure_info::message, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::detail::reporter::output_fail_prefix and micro_os_plus::micro_test_plus::detail::reporter::output_fail_suffix.
Referenced by micro_os_plus::micro_test_plus::detail::check_result::~check_result, micro_os_plus::micro_test_plus::test_case::fail_unexpected_exception and micro_os_plus::micro_test_plus::detail::reporter::pass_without_text.
fail_suite()
| virtual |
Reports a failure of a test suite outside its test cases.
Adds a "✗ <message> FAILED" line, at the indentation of the test cases, to the output buffer, which end_suite() displays.
- Parameters
-
message The message to display.
suite Reference to the test suite.
- Returns
Nothing.
Adds a "✗ <message> FAILED" line to the output buffer, indented as the test cases of the suite, with the same colours as the failed checks; since there is no source location, no parenthesised location follows. The line is displayed by end_suite(), with the other buffered output of the failed suite.
Declaration at line 229 of file reporter-human.h, definition at line 366 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_, micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::detail::endl, micro_os_plus::micro_test_plus::detail::colours::fail, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::detail::reporter::mark_failure, micro_os_plus::micro_test_plus::detail::runnable_base::name and micro_os_plus::micro_test_plus::detail::colours::none.
Referenced by operator=.
flush_streams()
|
Flushes the standard output stream and the output file.
Only the C streams are flushed; the internal output buffer is not written.
- Parameters
None.
- Returns
Nothing.
This member function flushes the stdout stream and, if open, the output file, so that everything already written to them becomes visible. It does not write the contents of the internal buffer.
Declaration at line 452 of file reporter.h, definition at line 622 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::output_file_.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::announce_output_file, begin_session, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_session, begin_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_suite, begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner, skip_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_suite, skip_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case.
has_output_file_error()
| nodiscard noexcept |
Returns whether the output file could not be opened.
Checked by runner::initialise(), which reports it on the console, as the option errors are, and declines the session, so that no test is run and runner::run_suites() returns 2.
- Parameters
None.
- Return Values
-
true The output file was requested but could not be opened.
false No output file was requested, or it was opened.
Returns the flag set by the constructor when fopen() failed.
Declaration at line 469 of file reporter.h, definition at line 636 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::has_output_file_error_.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner.
pass()
|
Reports a passed condition.
- Parameters
-
message The message to display.
expression The string representation of the expression.
test_case The test case that owns this check.
- Returns
Nothing.
Outputs a pass prefix, followed by either the provided message or, if the message is empty, the evaluated expression string itself. A pass suffix is then appended to complete the output.
Declaration at line 511 of file reporter.h, definition at line 751 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::detail::reporter::output_pass_prefix and micro_os_plus::micro_test_plus::detail::reporter::output_pass_suffix.
Referenced by micro_os_plus::micro_test_plus::detail::check_result::~check_result and micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner.
pass_without_text()
| virtual |
Ignores a passed check whose text is not written.
The human-readable report has no plan, and displays the passed checks only when they are written in full, so a check without text leaves no trace in it.
- Parameters
-
test_case The test case that owns this check.
- Returns
Nothing.
Does nothing; the passed checks are displayed only with the verbose verbosity, or written to the output file, and in both cases they are written in full, by pass().
Declaration at line 278 of file reporter-human.h, definition at line 718 of file reporter-human.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case.
Referenced by operator=.
skip_suite()
| virtual |
Reports a test suite skipped by the filter.
Displays a "• <name> - skipped (filtered)" line, instead of the suite body and results.
- Parameters
-
suite Reference to the skipped test suite.
- Returns
Nothing.
This member function writes a "• <name> - skipped (filtered)" line, instead of the suite body and results, to the output file (if open) and, with normal or verbose verbosity, to stdout, preceded on stdout by an empty line when add_empty_line_ is set. For silent or quiet verbosity levels, nothing is written to stdout.
Declaration at line 214 of file reporter-human.h, definition at line 334 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::skipped, micro_os_plus::micro_test_plus::detail::reporter::write_console and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
skip_test_case()
| virtual |
Reports a test case skipped by the filter.
Displays a "• <name> - skipped (filtered)" line, indented by its nesting depth.
- Parameters
-
test_case Reference to the skipped test case.
- Returns
Nothing.
As in begin_test_case(), for a nested test case, the results of the checks already performed by the outer test case, if any, are written first (see commit_outer_results()), so that the output follows the execution order.
A "• <name> - skipped (filtered)" line, indented according to the nesting depth, is then written to the output file (if open) and, with normal or verbose verbosity, to stdout, preceded by the names of the outer test cases, if not displayed yet, and on stdout by an empty line when add_empty_line_ is set. For silent or quiet verbosity levels, nothing is written to stdout.
Declaration at line 263 of file reporter-human.h, definition at line 677 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::commit_outer_results, micro_os_plus::micro_test_plus::detail::output_route::console, display_open_names, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::detail::reporter::indent_size_, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::test_case::nesting_depth, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::skipped, micro_os_plus::micro_test_plus::detail::test_case_heading, micro_os_plus::micro_test_plus::detail::reporter::write_console and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by operator=.
writes_passed_checks()
| nodiscard noexcept |
Returns whether the passed checks are written anywhere.
Called by test_case::expect() and test_case::require(), so that a passed check whose line is never written does not format its expression, its messages, or its line. The answer depends only on the verbosity and on the output file, which do not change during the session. A failed check is always formatted.
- Parameters
None.
- Return Values
-
true The lines of the passed checks reach the console or the output file, at least in some cases.
false The descriptions and the expressions of the passed checks are never written; the TAP reporter writes only their test points (see pass_without_text()).
The passed checks are written to the output file, when it is open, whatever the verbosity; to the console only with the verbose verbosity level. With the normal verbosity, only the failed checks (with the names of the open test cases) are displayed, so the passed checks are counted, without formatting them; the TAP reporter records their test points (see pass_without_text()).
Declaration at line 796 of file reporter.h, definition at line 320 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::output_file_, micro_os_plus::micro_test_plus::verbose and micro_os_plus::micro_test_plus::detail::reporter::verbosity_.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::comment_prefix and micro_os_plus::micro_test_plus::test_case::report_misdirected.
Protected Member Functions
announce_output_file()
| protected |
Tells the console where the output file was written.
Called by the derived classes at the end of the session, after the totals, or after the abort report. It writes a line that names the output file, prefixed with comment_prefix() so that it is valid in the output format, and flushes the streams, so that the file is complete when the line is displayed. Nothing is written if there is no output file, or with the silent verbosity.
- Parameters
None.
- Returns
Nothing.
The file is flushed before the line is written, so that the line is displayed only when the content of the file is complete. The file itself is closed by the destructor.
Declaration at line 1014 of file reporter.h, definition at line 244 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::output_file_, micro_os_plus::micro_test_plus::detail::reporter::output_file_path_, micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::detail::reporter::verbosity_ and micro_os_plus::micro_test_plus::detail::reporter::write_console.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, end_session and micro_os_plus::micro_test_plus::detail::reporter_tap::end_session.
clear_buffer()
| protected |
Clears the output buffer.
Also resets buffer_has_failures_, so that the flag always describes the current content of the buffer.
- Parameters
None.
- Returns
Nothing.
Empties buffer_ and failures_, keeping their capacity, and resets buffer_has_failures_.
Declaration at line 1029 of file reporter.h, definition at line 795 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_, micro_os_plus::micro_test_plus::detail::reporter::buffer_has_failures_ and micro_os_plus::micro_test_plus::detail::reporter::failures_.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case.
commit_outer_results()
| protected |
Writes the results of the outer test case, if any, before a nested test case begins or is skipped.
Called by begin_test_case() and skip_test_case() of the concrete reporters, so that the output follows the execution order.
- Parameters
None.
- Returns
Nothing.
For a nested test case, the outer test case may have performed checks before it; their results are written first, by commit_buffer(). For a top-level test case, the buffer is expected to be empty, since the checks are performed only by the test cases, and each one writes its results when it ends; should it not be, its content is written in the same way, rather than lost or attributed to the next test case, and the run continues.
Declaration at line 1181 of file reporter.h, definition at line 1013 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_ and micro_os_plus::micro_test_plus::detail::reporter::commit_buffer.
Referenced by begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, micro_os_plus::micro_test_plus::detail::reporter::commit_buffer, skip_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case.
console_lines()
| nodiscard noexcept protected |
Returns the buffered lines that the console displays when a test case or a suite ends, or when its results are committed.
With the verbose verbosity, all the buffered lines; with the normal verbosity, all the buffered lines of a failed test case or suite, otherwise none; with the quiet verbosity, only the lines of the failed checks; with the silent verbosity, none.
- Parameters
-
failed Whether the test case or the suite failed, or, when committing the results of an outer test case, whether the buffer contains a failed check.
The quiet verbosity displays the failed checks, and the buffer may also contain the passed checks, for the output file; the lines of the failed checks are therefore kept separately, in failures_.
Declaration at line 866 of file reporter.h, definition at line 332 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_, micro_os_plus::micro_test_plus::detail::reporter::failures_, micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::quiet, micro_os_plus::micro_test_plus::verbose and micro_os_plus::micro_test_plus::detail::reporter::verbosity_.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case.
display_open_test_cases()
| protected |
Displays the headings not yet displayed, of the open test cases.
Walks open_test_cases_ from the outermost test case and, for each one whose heading was not displayed yet, calls display_open_heading() and marks it as displayed. A failure in a nested test case also fails the outer ones, so their headings are displayed first, to show where the result is.
- Parameters
-
include_last Whether to display the heading of the innermost open test case too; false for the result of a passed test case, which is not preceded by its own heading.
- Returns
Nothing.
The innermost open test case is skipped unless include_last is true.
Declaration at line 1372 of file reporter.h, definition at line 382 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::display_open_heading, micro_os_plus::micro_test_plus::detail::reporter::open_test_case::name_displayed and micro_os_plus::micro_test_plus::detail::reporter::open_test_cases_.
Referenced by micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, display_open_names, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case.
enter_suite()
| protected |
Notes the suite that begins, for the headings displayed later.
Called by begin_suite() of the concrete reporters, with the information whether the heading of the suite was displayed.
- Parameters
-
suite The suite that begins.
displayed Whether the heading was written to the console.
- Returns
Nothing.
Records the suite and whether its heading was displayed; the quiet verbosity displays it later, if the suite has a failure.
Declaration at line 913 of file reporter.h, definition at line 409 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::current_suite_ and micro_os_plus::micro_test_plus::detail::reporter::suite_displayed_.
Referenced by begin_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_suite and micro_os_plus::micro_test_plus::detail::reporter::comment_prefix.
mark_failure()
| protected |
Records that the lines appended to the buffer from a given position are a failure.
Sets buffer_has_failures_ and, with the quiet verbosity, which displays only the failures, copies the lines to failures_.
- Parameters
-
begin The position in buffer_ where the lines of the failure begin.
- Returns
Nothing.
Only the quiet verbosity needs the copy, since the other levels display the buffer as a whole, or nothing.
Declaration at line 897 of file reporter.h, definition at line 367 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_, micro_os_plus::micro_test_plus::detail::reporter::buffer_has_failures_, micro_os_plus::micro_test_plus::detail::reporter::failures_, micro_os_plus::micro_test_plus::quiet and micro_os_plus::micro_test_plus::detail::reporter::verbosity_.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, micro_os_plus::micro_test_plus::detail::reporter::fail, fail_suite and micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite.
route()
| nodiscard noexcept protected |
Tells where a kind of record is written.
The single place of the output policy. The output file receives all the records, whatever the verbosity, so that its content does not depend on the console. The console receives, with each verbosity level:
- silent: nothing;
- quiet: the failed checks, the failures of the suites, the totals, and the report of an aborted execution;
- normal: in addition, the informational lines, the headings and results of the suites, the results of the test cases, and the skipped suites and test cases;
- verbose: in addition, the headings of the test cases and the lines of the passed checks.
The headings of the test cases that contain a failure are also displayed with the normal verbosity (see console_lines()), but the passed checks are not; they are counted, without being formatted (see writes_passed_checks()), and the TAP reporter records their test points (see pass_without_text()). The concrete reporters adapt the quiet and normal levels to their format.
- Parameters
-
kind The kind of record.
- Returns
The destinations of the record.
The file receives all the records, when it is open, so that its content does not depend on the verbosity (a file of a silent run is as complete as that of a verbose one). The console follows the verbosity levels, as documented in the declaration.
Declaration at line 847 of file reporter.h, definition at line 280 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::abort, micro_os_plus::micro_test_plus::detail::failed_check, micro_os_plus::micro_test_plus::detail::info, micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::detail::reporter::output_file_, micro_os_plus::micro_test_plus::detail::passed_check, micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::detail::test_case_heading, micro_os_plus::micro_test_plus::detail::total, micro_os_plus::micro_test_plus::verbose and micro_os_plus::micro_test_plus::detail::reporter::verbosity_.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, begin_session, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_session, begin_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_suite, begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, skip_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_suite, skip_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case and micro_os_plus::micro_test_plus::detail::reporter::write_info.
write_buffer_to_file()
| protected |
Writes the current buffered content to the output file.
The buffer is written without appending a line ending, and is not cleared. ANSI colour sequences are removed, so the file receives plain text even when the console output is coloured. If no output file is open, the call has no effect.
- Parameters
None.
- Returns
Nothing.
Writes the contents of buffer_ to output_file_ without appending a newline. If output_file_ is null, the call is a no-op.
The buffer may contain ANSI colour sequences, added when the console is a terminal, which must not reach the file; they are removed by write_without_colours().
Declaration at line 816 of file reporter.h, definition at line 425 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::buffer_ and micro_os_plus::micro_test_plus::detail::reporter::output_file_.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case.
write_console()
| protected |
Writes formatted text to the console.
All reporter console output is routed through this function, so that it reaches the standard output stream via a single path, shared with the output of the user printf() calls. Using one stream-based path keeps the reporter and user output in the same buffer, preserving their relative order.
- Parameters
-
format A printf()-style format string.
... The arguments referred to by the format string.
- Returns
Nothing.
The arguments are forwarded to vfprintf() on stdout. The stream is explicit, so the compiler does not rewrite the call into puts() or putchar(), and all console output shares the same FILE-based path.
Declaration at line 931 of file reporter.h, definition at line 444 of file reporter.cpp.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::announce_output_file, begin_session, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_session, begin_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_suite, begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, display_open_heading, micro_os_plus::micro_test_plus::detail::reporter_tap::display_open_heading, display_open_names, end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, skip_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_suite, skip_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::write_quiet_failures.
write_console_text()
| protected |
Writes a text to the console, unchanged.
The text is written with its size, not as a C string, so that a zero character in a message does not end the output. No line ending is appended.
- Parameters
-
text The text to write.
- Returns
Nothing.
The text is written with its size, not as a C string, so that a zero character in a message does not end the output.
Declaration at line 881 of file reporter.h, definition at line 355 of file reporter.cpp.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::write_quiet_failures.
write_file()
| protected |
Writes formatted text to the output file.
If no output file is open, the call has no effect, so callers do not need to check output_file_ themselves.
- Parameters
-
format A printf()-style format string.
... The arguments referred to by the format string.
- Returns
Nothing.
The arguments are forwarded to vfprintf() on output_file_. If output_file_ is null, the arguments are ignored.
Declaration at line 950 of file reporter.h, definition at line 458 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::output_file_.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::comment_prefix and micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case.
write_info()
| protected |
Writes the informational (non-result) lines to the console and to the output file.
- Parameters
-
arguments The command line of the session, listed when not empty; passed by begin_session() from the runner options, so that the reporter does not keep a copy.
- Returns
Nothing.
Constructs and emits two informational lines, each prefixed by comment_prefix(): the first lists the program name (without the path) and any command-line arguments; the second identifies the compiler (Clang, GCC, or MSVC) together with the version string, floating-point availability on bare-metal targets, exception support, and any active debug or trace macros. Both lines are written to the output file when one is open, and to stdout when the verbosity is normal or verbose (see route()), except when both MICRO_OS_PLUS_STARTUP_ENABLED and MICRO_OS_PLUS_DIAG_TRACE_ENABLED are defined, since the startup code already displays this information.
Declaration at line 994 of file reporter.h, definition at line 547 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, micro_os_plus::micro_test_plus::detail::output_route::console, micro_os_plus::micro_test_plus::utility::extract_file_name, micro_os_plus::micro_test_plus::detail::info, micro_os_plus::micro_test_plus::detail::reporter::route and micro_os_plus::micro_test_plus::detail::reporter::write_line.
Referenced by begin_session, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_session and micro_os_plus::micro_test_plus::detail::reporter::comment_prefix.
write_line()
| protected |
Writes formatted lines to the output file and, when requested, to the console.
The text is formatted once, and the same text is written to the output file, if open, and, when to_console is true, to stdout. As in write_buffer_to_file(), the ANSI colour sequences are removed from the file copy, so a console line with colours and its plain file line are written by one call. The format normally ends with a line ending; any empty line or buffered output that precedes the console line is written by the caller, before this call.
- Parameters
-
to_console Whether to write the text to stdout as well.
format A printf()-style format string.
... The arguments referred to by the format string.
- Returns
Nothing.
The text is formatted with vsnprintf() into a local array, which holds the usual lines without an allocation; a longer text, for example with a long test name, is formatted again, from a copy of the arguments, into a string of the exact length. The array is kept small, since the lines that end the nested test cases are written at the deepest point of the stack. The text is then written with its length to the output file, without the colour sequences (see write_without_colours()), and, when requested, to stdout, unchanged. When there is nowhere to write, or the formatting fails, nothing is written.
Declaration at line 977 of file reporter.h, definition at line 485 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::detail::reporter::output_file_.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, begin_session, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_session, begin_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_suite, begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, micro_os_plus::micro_test_plus::detail::reporter::comment_prefix, end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, skip_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_suite, skip_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case and micro_os_plus::micro_test_plus::detail::reporter::write_info.
Private Member Functions
commit_buffer()
| virtual |
Writes the results buffered for the outer test case before a nested test case begins.
Keeps the report in execution order, with the checks of the outer test case before the nested test case.
- Parameters
None.
- Returns
Nothing.
The buffered results of the outer test case are always written to the output file (as end_test_case() does) and, with verbose verbosity, to stdout. With normal or quiet verbosity, they are written to stdout only when they include a failure (with quiet verbosity, only the failed checks), preceded by the headings of the suite and of the outer test case, which these verbosity levels otherwise display only when the test case ends. The buffer is then cleared, so that the nested test case starts with an empty buffer, and the remaining results of the outer test case are written by its end_test_case().
With normal verbosity, the passed checks committed here are not displayed, even if the outer test case fails later; the output file always contains them.
Declaration at line 379 of file reporter-human.h, definition at line 829 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::buffer_has_failures_, micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, micro_os_plus::micro_test_plus::detail::reporter::console_lines, display_open_names, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::test_case_heading, micro_os_plus::micro_test_plus::detail::reporter::write_buffer_to_file, micro_os_plus::micro_test_plus::detail::reporter::write_console and micro_os_plus::micro_test_plus::detail::reporter::write_console_text.
Referenced by operator=.
display_open_heading()
| virtual |
Writes the heading of an open test case.
Writes the indented "• <name>" line, preceded by an empty line before the first heading of a call, unless add_empty_line_ is set, in which case the caller has already written it.
- Parameters
-
open The open test case.
is_first Whether this is the first heading written by the current call of display_open_names().
- Returns
Nothing.
Writes the indented "• <name>" line. An empty line is written before the first one, unless add_empty_line_ is set, in which case the caller has already written it.
Declaration at line 417 of file reporter-human.h, definition at line 901 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::detail::reporter::indent_size_, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::test_case::nesting_depth, micro_os_plus::micro_test_plus::detail::reporter::open_test_case::test and micro_os_plus::micro_test_plus::detail::reporter::write_console.
Referenced by operator=.
display_open_names()
|
Displays the headings not yet displayed, of the suite and of the open test cases.
With normal verbosity, the test case headings are displayed only when something is displayed under them: a failure, or the result of a nested test case; with quiet verbosity, the suite heading too. A failure in a nested test case also fails the outer ones, so their headings are displayed first, outermost first, to show where the result is.
- Parameters
-
include_last Whether to display the heading of the innermost open test case too; false for the result of a passed test case, which is not preceded by its own heading.
- Returns
Nothing.
If the heading of the suite was not displayed (with quiet verbosity), it is displayed first, followed by an empty line. Then displays, on stdout, the indented "• <name>" line of each open test case whose name was not displayed yet (see display_open_test_cases()). The innermost one is skipped unless include_last is true.
Declaration at line 400 of file reporter-human.h, definition at line 876 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::add_empty_line_, micro_os_plus::micro_test_plus::detail::reporter::current_suite_, micro_os_plus::micro_test_plus::detail::reporter::display_open_test_cases, micro_os_plus::micro_test_plus::detail::runnable_base::name, micro_os_plus::micro_test_plus::detail::reporter::suite_displayed_ and micro_os_plus::micro_test_plus::detail::reporter::write_console.
Referenced by abort_session, commit_buffer, end_suite, end_test_case, operator= and skip_test_case.
output_fail_prefix()
| virtual |
Outputs the prefix for a failing condition.
- Parameters
-
message The message to display.
has_expression Whether the failure is associated with an expression.
location The source location of the failure.
test_case The test case that owns this check.
- Returns
Nothing.
This member function outputs the prefix for a failing check result, indented one level deeper than the test case. The prefix includes a cross symbol (✗), an optional message, and the label "FAILED", both symbol and label in the fail colour. The source location (file name and line number) follows, after an opening parenthesis; when the failure has an expression, a comma separator is added, so that the expression follows inside the parentheses.
Declaration at line 346 of file reporter-human.h, definition at line 595 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::utility::extract_file_name, micro_os_plus::micro_test_plus::detail::colours::fail, micro_os_plus::micro_test_plus::reflection::source_location::file_name, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::reflection::source_location::line, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::test_case::nesting_depth and micro_os_plus::micro_test_plus::detail::colours::none.
Referenced by operator=.
output_fail_suffix()
| virtual |
Outputs the suffix for a failing condition.
- Parameters
-
location The source location of the failure.
kind The kind of the check; for check_kind::requirement, the effect that follows (the test case is stopped, or the test execution is aborted) is displayed.
test_case The test case that owns this check.
- Returns
Nothing.
This member function outputs the suffix for a failing check result by closing the parenthesis, appending, if the check is a requirement, the effect that follows, and then appending endl, which adds a line ending. As for a pass, the streams are flushed when the test case ends.
The effect depends on the build, as in check_result: with exceptions, only the test case is stopped (" - test case stopped"), and the run continues with the next test case; without, the test execution is aborted (" - test execution aborted").
Declaration at line 362 of file reporter-human.h, definition at line 646 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::endl, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case and micro_os_plus::micro_test_plus::detail::requirement.
Referenced by operator=.
output_pass_prefix()
| virtual |
Outputs the prefix for a passing condition.
- Parameters
-
message The message to display.
test_case The test case that owns this check.
- Returns
Nothing.
This member function outputs the prefix for a passing check result, indented one level deeper than the test case. The prefix includes a tick symbol (✓), in the pass colour, and, if provided, the associated message. Colour formatting is reset immediately after the symbol.
The prefix/suffix member functions help shorten the code generated by the template member functions.
Declaration at line 321 of file reporter-human.h, definition at line 554 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::reporter::colours_, micro_os_plus::micro_test_plus::detail::indent, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::test_case::nesting_depth, micro_os_plus::micro_test_plus::detail::colours::none and micro_os_plus::micro_test_plus::detail::colours::pass.
Referenced by operator=.
output_pass_suffix()
| virtual |
Outputs the suffix for a passing condition.
- Parameters
-
test_case The test case that owns this check.
- Returns
Nothing.
Completes the pass output by appending endl, which adds a line ending to the buffer. The streams are not flushed, since nothing was written to them; the buffer is written, and the streams flushed, when the test case ends.
The prefix/suffix member functions help shorten the code generated by the template member functions.
Declaration at line 332 of file reporter-human.h, definition at line 578 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::detail::endl and micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case.
Referenced by operator=.
Protected Member Attributes
add_empty_line_
| protected |
Whether to write an empty line before the next console output.
Set and cleared by the concrete reporters, to separate the groups of console lines, such as the suites and the failed test cases; the output file is not affected.
Definition at line 1434 of file reporter.h.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, begin_session, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_session, begin_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_suite, begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, commit_buffer, micro_os_plus::micro_test_plus::detail::reporter_tap::commit_buffer, display_open_heading, micro_os_plus::micro_test_plus::detail::reporter_tap::display_open_heading, display_open_names, end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, skip_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::skip_suite, skip_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case.
buffer_
| protected |
Output accumulation buffer.
Accumulates all reporter output until it is written to the console or the output file via write_console_text() or write_buffer_to_file().
Definition at line 1294 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, micro_os_plus::micro_test_plus::detail::reporter::commit_outer_results, micro_os_plus::micro_test_plus::detail::reporter::console_lines, micro_os_plus::micro_test_plus::detail::reporter::end_line, micro_os_plus::micro_test_plus::detail::reporter::fail, fail_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite, micro_os_plus::micro_test_plus::detail::reporter::mark_failure, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter::operator<<, micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_prefix, micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix, micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_prefix, micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_suffix and micro_os_plus::micro_test_plus::detail::reporter::write_buffer_to_file.
buffer_has_failures_
| protected |
Whether the output buffer contains a failed check.
Set by fail() and reset by clear_buffer(). When a nested test case begins, the concrete reporters use it to decide whether the results already buffered for the outer test case are displayed with normal verbosity.
Definition at line 1305 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, commit_buffer and micro_os_plus::micro_test_plus::detail::reporter::mark_failure.
colours_
| protected |
ANSI colour codes for output formatting.
Empty strings by default; the human-readable reporter assigns detail::colours_red_green when colours are enabled by runner_options::colour, explicitly or because the console is a terminal.
Definition at line 1284 of file reporter.h.
Referenced by reporter_human, abort_session, end_session, end_suite, end_test_case, fail_suite, output_fail_prefix and output_pass_prefix.
current_suite_
| protected |
The suite that has begun and not yet ended.
Set by enter_suite(); null outside the suites.
Definition at line 1399 of file reporter.h.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, display_open_names, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, micro_os_plus::micro_test_plus::detail::reporter::enter_suite and micro_os_plus::micro_test_plus::detail::reporter_tap::write_quiet_failures.
expression_
| protected |
Expression formatter for pass and fail reporting.
Used by the checks (test_case::expect(), test_case::require(), and detail::check_result), which are friends, to pre-format expressions at construction time; pass() and fail() then append the formatted text to buffer_. The applications format their own types by defining operator<< for the public expression_formatter alias.
Definition at line 1423 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::check_result::~check_result and micro_os_plus::micro_test_plus::test_case::report_misdirected.
failures_
| protected |
The lines of the failed checks, for the quiet verbosity.
With the quiet verbosity, the console displays only the failed checks, while buffer_ may also contain the passed checks, for the output file. Filled by mark_failure() and emptied by clear_buffer(); not used with the other verbosity levels.
Definition at line 1316 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::clear_buffer, micro_os_plus::micro_test_plus::detail::reporter::console_lines, micro_os_plus::micro_test_plus::detail::reporter::mark_failure and micro_os_plus::micro_test_plus::detail::reporter_tap::write_quiet_failures.
has_output_file_error_
| protected |
Whether the output file could not be opened.
Set by the constructor, and returned by has_output_file_error(). Kept next to the other flags, so that the class does not end with padding, which the derived classes would report.
Definition at line 1444 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::reporter and micro_os_plus::micro_test_plus::detail::reporter::has_output_file_error.
open_test_cases_
| protected |
The test cases that have begun and not yet ended, outermost first.
The last element is the test case that owns the buffered results.
Definition at line 1352 of file reporter.h.
Referenced by abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, micro_os_plus::micro_test_plus::detail::reporter::display_open_test_cases, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::write_quiet_failures.
output_file_
| protected |
Optional output file, receiving a copy of the test report.
When non-null, the report is written to this file in addition to the console, without colour sequences. The file receives the full report, regardless of the verbosity. The file is opened by the constructor and closed by the destructor.
Definition at line 1465 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::reporter::~reporter, micro_os_plus::micro_test_plus::detail::reporter::announce_output_file, micro_os_plus::micro_test_plus::detail::reporter::flush_streams, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::reporter::write_buffer_to_file, micro_os_plus::micro_test_plus::detail::reporter::write_file, micro_os_plus::micro_test_plus::detail::reporter::write_line and micro_os_plus::micro_test_plus::detail::reporter::writes_passed_checks.
output_file_path_
| protected |
Path of the optional output file.
Copied by the constructor from the session options. Used to name the file in the confirmation message displayed when the file is closed (not displayed with the silent verbosity).
Definition at line 1454 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::reporter::~reporter and micro_os_plus::micro_test_plus::detail::reporter::announce_output_file.
suite_displayed_
| protected |
Whether the heading of the current suite was displayed on the console.
Set by enter_suite(); with the quiet verbosity, which does not display the headings, the heading is displayed when the first failure of the suite is.
Definition at line 1410 of file reporter.h.
Referenced by abort_session, display_open_names and micro_os_plus::micro_test_plus::detail::reporter::enter_suite.
verbosity_
| protected |
The verbosity level for test reporting.
A copy of the level kept by the runner, set by the constructor from the same session options and not changed afterwards. The public accessor is runner::verbosity_level().
Definition at line 1273 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::reporter, micro_os_plus::micro_test_plus::detail::reporter::announce_output_file, micro_os_plus::micro_test_plus::detail::reporter::console_lines, micro_os_plus::micro_test_plus::detail::reporter::mark_failure, micro_os_plus::micro_test_plus::detail::reporter_tap::pass_without_text, micro_os_plus::micro_test_plus::detail::reporter::route, micro_os_plus::micro_test_plus::detail::reporter::verbosity and micro_os_plus::micro_test_plus::detail::reporter::writes_passed_checks.
Protected Static Functions
format_elapsed_time()
| protected static |
Formats the elapsed time of a suite or of the session.
The text is appended to the summary lines by the concrete reporters, in the form ", time: 1.234 ms"; it is empty when the stopwatch has no elapsed time, so that the summary lines remain identical on the platforms without a clock.
The array has a fixed size, known at compile time, so that the compiler can verify that the text is never truncated.
- Parameters
-
stopwatch The stopwatch of the suite or of the runner.
message The character array that receives the null-terminated text.
- Returns
Nothing.
The elapsed time, in microseconds, is displayed in milliseconds, with three decimals. When it is zero, either because the stopwatch has no readings or because the interval was shorter than a microsecond, the text is empty.
Declaration at line 1061 of file reporter.h, definition at line 810 of file reporter.cpp.
References micro_os_plus::micro_test_plus::detail::stopwatch::elapsed and micro_os_plus::micro_test_plus::detail::reporter::elapsed_time_size_.
Referenced by end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite and micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite.
format_session_totals()
| protected static |
Formats the totals of the test session.
The text is the part of the session summary line common to the concrete reporters, in the form "7 checks passed, 1 failed, in 3 test cases, 2 test suites"; the numbers of test cases and of suites skipped by the filter follow the respective counts, as ", 1 skipped", only when not zero. The label (Total: or total:), the markers, and the elapsed time are added by the callers.
- Parameters
-
runner The runner of the test session.
message The character array that receives the null-terminated text.
- Returns
Nothing.
The suites are counted by runner::total_suites_count(), which includes the suites skipped by the filter, counted separately by runner::skipped_suites_count().
Declaration at line 1104 of file reporter.h, definition at line 896 of file reporter.cpp.
References micro_os_plus::micro_test_plus::counters::executed_test_cases, micro_os_plus::micro_test_plus::counters::failed_checks, MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner, micro_os_plus::micro_test_plus::counters::passed_checks, micro_os_plus::micro_test_plus::runner::skipped_suites_count, micro_os_plus::micro_test_plus::counters::skipped_test_cases, micro_os_plus::micro_test_plus::runner::total_suites_count, micro_os_plus::micro_test_plus::runner::totals and micro_os_plus::micro_test_plus::detail::reporter::totals_size_.
Referenced by end_session and micro_os_plus::micro_test_plus::detail::reporter_tap::end_session.
format_suite_totals()
| protected static |
Formats the totals of a suite.
The text is the part of the suite result line common to the concrete reporters: "7 checks in 3 test cases" for a passed suite, and "6 checks passed, 1 failed, in 3 test cases" for a failed one; the number of test cases skipped by the filter follows, as ", 1 skipped", only when not zero. The status, the enclosing markers, and the elapsed time are added by the callers.
- Parameters
-
suite The suite that ended.
message The character array that receives the null-terminated text.
- Returns
Nothing.
A passed suite has no failed checks, so only the number of checks is shown.
Declaration at line 1125 of file reporter.h, definition at line 933 of file reporter.cpp.
References micro_os_plus::micro_test_plus::counters::executed_test_cases, micro_os_plus::micro_test_plus::counters::failed_checks, MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE, micro_os_plus::micro_test_plus::counters::passed, micro_os_plus::micro_test_plus::counters::passed_checks, micro_os_plus::micro_test_plus::counters::skipped_test_cases, micro_os_plus::micro_test_plus::detail::runnable_base::totals and micro_os_plus::micro_test_plus::detail::reporter::totals_size_.
Referenced by end_suite and micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite.
format_test_case_totals()
| protected static |
Formats the totals of a test case.
The text is the part of the test case result line common to the concrete reporters: "7 checks" for a passed test case, and "6 checks passed, 1 failed" for a failed one, followed by the number of failed nested test cases, as ", 1 test case failed", only when not zero, since a test case may fail because of a nested one alone. The status and the enclosing markers are added by the callers.
- Parameters
-
test_case The test case that ended.
message The character array that receives the null-terminated text.
- Returns
Nothing.
A passed test case has no failed checks and no failed nested test cases, so only the number of checks is shown.
Declaration at line 1146 of file reporter.h, definition at line 970 of file reporter.cpp.
References micro_os_plus::micro_test_plus::counters::failed_checks, micro_os_plus::micro_test_plus::counters::failed_test_cases, MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE, micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::test_case, micro_os_plus::micro_test_plus::counters::passed, micro_os_plus::micro_test_plus::counters::passed_checks, micro_os_plus::micro_test_plus::detail::runnable_base::totals and micro_os_plus::micro_test_plus::detail::reporter::totals_size_.
Referenced by end_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case.
Protected Static Attributes
elapsed_time_size_
| constexpr protected static |
Size of the array that receives the elapsed time text.
Large enough for ", time: 4294967295.999 ms", the longest text produced by format_elapsed_time() (26 bytes with the terminator), and for the worst case assumed by GCC 11, which does not know that the fraction is below 1000 and counts ten digits for it (33 bytes).
Definition at line 1040 of file reporter.h.
Referenced by end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite and micro_os_plus::micro_test_plus::detail::reporter::format_elapsed_time.
indent_size_
| constexpr protected static |
Number of spaces per nesting level.
Used by the concrete reporters to indent the lines of the nested test cases; four spaces is also the TAP 14 subtest indentation.
Definition at line 1263 of file reporter.h.
Referenced by begin_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case, display_open_heading, micro_os_plus::micro_test_plus::detail::reporter_tap::display_open_heading, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case, micro_os_plus::micro_test_plus::detail::reporter::operator<<, skip_test_case and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case.
totals_size_
| constexpr protected static |
Size of the array that receives the totals text.
Large enough for the longest text produced by format_session_totals(), which is longer than the texts of the suites and of the test cases: 53 characters, four counts, two fragments of up to 20 characters and a count each (the longest fragment is ", N test cases failed"), and the terminator, with the counts of the largest size_t value (10 digits on 32-bit targets, 20 on 64-bit ones). The fragments are counted at their maximum length, as the compiler does when it checks for truncation.
The array is a local variable of the functions that end the test cases, which run at the deepest point of the stack, so it is not larger than needed on the 32-bit embedded targets.
Definition at line 1082 of file reporter.h.
Referenced by end_session, micro_os_plus::micro_test_plus::detail::reporter_tap::end_session, end_suite, micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite, end_test_case, 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.
Deprecated Functions
verbosity()
| inline nodiscard noexcept |
Deprecated access to the verbosity level.
Kept from the v5.0.1 reporter class, for the applications that read it through the deprecated runner::reporter() (tr.reporter ().verbosity ()). The level is the one returned by runner::verbosity_level(), from the same session options.
- Parameters
None.
- Returns
The verbosity level of the session.
- Deprecated
-
use runner::verbosity_level() (since 6.0.0)
Returns the level stored in verbosity_, set by the constructor.
Declaration at line 492 of file reporter.h, definition at line 110 of file reporter-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::reporter::verbosity_.
Referenced by micro_os_plus::micro_test_plus::detail::reporter::micro_test_plus::runner.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.