reporter_human Class
Human (standard output) implementation of reporter. More...
Declaration
Included Headers
Base class
| class | reporter |
|
Reporter to display test results, including operand values and types for failures. More... | |
Public Constructors Index
| reporter_human (const reporter_human &)=delete | |
|
Deleted copy constructor to prevent copying. More... | |
| reporter_human (reporter_human &&)=delete | |
|
Deleted move constructor to prevent moving. More... | |
| reporter_human (std::unique_ptr< std::vector< std::string_view > > argvs) | |
|
Constructor for the reporter_human class. 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_human & | operator<< (detail::indent_t m) |
|
Output operator for the indent_t manipulator. More... | |
| reporter & | operator<< (reporter &(*func)(reporter &)) |
|
Output operator to display the 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, with type suffixes. 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 | begin_session (runner &runner) override |
|
Mark the beginning of a test session. More... | |
| void | begin_subtest (subtest &subtest) override |
|
Mark the beginning of a subtest. More... | |
| void | begin_suite (suite &suite) override |
|
Mark the beginning of a suite. More... | |
| void | end_session (runner &runner) override |
|
Mark the end of a test session. More... | |
| void | end_subtest (subtest &subtest) override |
|
Mark the end of a subtest. More... | |
| void | end_suite (suite &suite) override |
|
Mark the end of a test suite. More... | |
| void | endline (void) |
|
Inserts a line ending into the output buffer. More... | |
| detail::expression_formatter & | expression () |
|
Provides access to the expression formatter for this reporter. More... | |
| void | fail (bool abort, std::string &message, const std::string &expression, bool has_expression, const reflection::source_location &location, subtest &subtest) |
|
Report a failed condition. More... | |
| void | flush (void) |
|
Flush the current buffered content. More... | |
| const char * | get_comment_prefix (void) override |
|
Returns an empty comment prefix string. More... | |
| void | pass (std::string &message, const std::string &expression, subtest &subtest) |
|
Report a passed condition. More... | |
| micro_test_plus::verbosity | verbosity () const |
|
Returns the current verbosity level. More... | |
| void | write_buffer_to_stdout (void) |
|
Output the current buffered content. More... | |
Protected Member Functions Index
| auto | colour_ (const bool cond) const |
|
Selects the appropriate colour code based on a condition. More... | |
| void | output_fail_prefix_ (std::string &message, const bool has_expression, const reflection::source_location &location, subtest &subtest) override |
|
Outputs the prefix for a failing condition. More... | |
| void | output_fail_suffix_ (const reflection::source_location &location, bool abort, subtest &subtest) override |
|
Outputs the suffix for a failing condition. More... | |
| void | output_pass_prefix_ (std::string &message, subtest &subtest) override |
|
Outputs the prefix for a passing condition. More... | |
| void | output_pass_suffix_ (subtest &subtest) override |
|
Outputs the suffix for a passing condition. More... | |
| void | write_buffer_to_file_ (void) |
| void | write_info_ (void) |
|
Appends informational (non-result) text to the output buffer. More... | |
Protected Member Attributes Index
| bool | add_empty_line_ { true } |
|
Controls whether to add an empty line between successful test cases. More... | |
| std::unique_ptr< std::vector< std::string_view > > | argvs_ {} |
|
Owns the command-line arguments passed to the test runner. More... | |
| std::string | buffer_ {} |
|
Output accumulation buffer. More... | |
| detail::colours | colours_ {} |
|
ANSI colour codes for output formatting. More... | |
| detail::expression_formatter | expression_ { colours_ } |
|
Expression formatter for pass and fail reporting. More... | |
| FILE * | output_file_ { nullptr } |
|
Optional output file for redirecting test report output. More... | |
| const char * | output_file_path_ { nullptr } |
|
Optional file path for redirecting test report output. More... | |
| enum verbosity | verbosity_ = verbosity::normal |
|
The verbosity level for test reporting. More... | |
Description
Human (standard output) implementation of reporter.
reporter_human provides the default concrete implementation of the reporter abstract interface, formatting and presenting test results using printf-based output. It accumulates output in an internal string buffer and writes it to the standard output stream, supporting colour-coded diagnostics and multiple verbosity levels.
Users who require custom output behaviour (e.g. redirecting to a serial port on bare-metal targets) may derive a new class from reporter and supply an instance via the reporter global pointer before calling initialize().
All members and methods are defined within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.
Definition at line 101 of file reporter-human.h.
Public Constructors
reporter_human()
| delete |
Deleted copy constructor to prevent copying.
Definition at line 115 of file reporter-human.h.
Reference reporter_human.
reporter_human()
| delete |
Deleted move constructor to prevent moving.
Definition at line 120 of file reporter-human.h.
Reference reporter_human.
reporter_human()
|
Constructor for the reporter_human class.
- Parameters
-
argvs Owning pointer to the command-line arguments vector; the reporter takes ownership via move.
Delegates construction to the reporter base class with the supplied argument vector. On POSIX platforms, if stdout is connected to a terminal (isatty()), colour output is enabled by selecting the red/green colour scheme. If tracing is enabled, the function signature is output for diagnostic purposes.
Declaration at line 110 of file reporter-human.h, definition at line 84 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::reporter, micro_os_plus::micro_test_plus::reporter::colours_ and micro_os_plus::micro_test_plus::detail::colours_red_green.
Referenced by reporter_human, reporter_human, operator<<, operator= and operator=.
Public Destructor
~reporter_human()
|
Destructor for the reporter_human class.
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 139 of file reporter-human.h, definition at line 107 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.
Definition at line 153 of file reporter-human.h.
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. It enables efficient streaming of individual characters into the reporter, supporting precise and flexible formatting of test output across all test cases and folders.
Declaration at line 153 of file reporter-human.h, definition at line 416 of file reporter.cpp.
operator<<()
|
Output operator for a constant character string.
- Parameters
-
s The string to output.
- 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. It enables efficient streaming of string literals and character arrays into the reporter, supporting clear and flexible formatting of test output across all test cases and folders.
Declaration at line 153 of file reporter-human.h, definition at line 431 of file reporter.cpp.
operator<<()
|
Output operator for the indent_t manipulator.
- 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 corresponding to m.level two-space indentation levels. It enables structured, readable nesting of test output across all test cases and folders by allowing *this << indent(n) << "text" chaining.
Declaration at line 149 of file reporter-human.h, definition at line 134 of file reporter-human.cpp.
References reporter_human, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::indent_size and micro_os_plus::micro_test_plus::detail::indent_t::level.
operator<<()
Output operator to display the 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, allowing for seamless integration of stream operations and improved readability of test output across all test cases and folders.
Declaration at line 153 of file reporter-human.h, definition at line 386 of file reporter.cpp.
References micro_os_plus::micro_test_plus::reporter::argvs_ and get_comment_prefix.
operator<<()
|
Output operator for nullptr.
- Returns
Reference to the current reporter instance.
Definition at line 153 of file reporter-human.h.
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. It enables seamless streaming of string data into the reporter, supporting clear and efficient formatting of test output across all test cases and folders.
Declaration at line 153 of file reporter-human.h, definition at line 402 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::reporter::endline.
operator<<()
|
Output operator to display any pointer.
- Template Parameters
-
T The type of the pointer.
- Parameters
-
v The pointer value to output.
- Returns
Reference to the current reporter instance.
This operator overload enables the reporter to output pointer values in a consistent and readable format.
Null pointers are always rendered as the string "nullptr", regardless of the platform, avoiding platform-specific behaviour such as "(nil)" on Linux/glibc or "0x0" on macOS.
Non-null pointers are formatted as a hexadecimal address using snprintf with the p format specifier. The resulting string is appended to the internal output buffer, allowing pointer values to be included in test reports and diagnostics.
This approach provides clear and unambiguous representation of pointer addresses, which is particularly useful for debugging and verifying pointer-related test cases.
Declaration at line 153 of file reporter-human.h, definition at line 144 of file reporter-inlines.h.
operator<<()
|
Output operator for arithmetic types, with type suffixes.
- 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 append_number_ helper function, which handles the conversion to a string representation with appropriate type suffixes where applicable (e.g., "f" for float, "l" for long double). This enables numeric values to be included in test reports and diagnostics in a clear and unambiguous manner, supporting the verification of test cases that involve arithmetic expressions and comparisons.
Declaration at line 153 of file reporter-human.h, definition at line 184 of file reporter-inlines.h.
operator=()
| delete |
Deleted copy assignment operator to prevent copying.
Definition at line 126 of file reporter-human.h.
Reference reporter_human.
operator=()
| delete |
Deleted move assignment operator to prevent moving.
Definition at line 133 of file reporter-human.h.
Reference reporter_human.
Public Member Functions
begin_session()
| virtual |
Mark 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 report" heading is then written both to the output file (if open) and to stdout. The add_empty_line_ flag is set so that subsequent suite output is visually separated.
Declaration at line 165 of file reporter-human.h, definition at line 151 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::flush, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::reporter::verbosity_ and micro_os_plus::micro_test_plus::reporter::write_info_.
begin_subtest()
| virtual |
Mark the beginning of a subtest.
- Parameters
-
subtest Reference to the subtest.
- Returns
Nothing.
This method marks the beginning of a test case, setting the internal state to indicate that test output is now within a test case context. If there is pending output and the verbosity level is set to verbose, it ensures that output is properly separated and displayed, adding an empty line if necessary. The output buffer is cleared and the stream is flushed to guarantee that all previous output is visible before the new test case begins. This approach enhances the clarity and organisation of test results across all test cases and folders.
Declaration at line 205 of file reporter-human.h, definition at line 489 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::reporter::flush, micro_os_plus::micro_test_plus::indent, micro_os_plus::micro_test_plus::indent_size, micro_os_plus::micro_test_plus::detail::test_node::name, micro_os_plus::micro_test_plus::subtest::nesting_depth, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::verbose and micro_os_plus::micro_test_plus::reporter::verbosity_.
begin_suite()
| virtual |
Mark the beginning of a suite.
- Parameters
-
suite Reference to the suite.
- Returns
Nothing.
This method marks the beginning of a test suite, ensuring that output is properly separated and clearly presented. If there is pending output, the stream is flushed and an empty line is added for clarity. For silent or quiet verbosity levels, output is suppressed. Otherwise, a message indicating the start of the test suite is displayed. This approach enhances the organisation and readability of test results across all test cases and folders.
Declaration at line 185 of file reporter-human.h, definition at line 296 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::flush, micro_os_plus::micro_test_plus::detail::test_node::name, micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::verbose and micro_os_plus::micro_test_plus::reporter::verbosity_.
end_session()
| virtual |
Mark the end of a test session.
- Parameters
-
runner Reference to the test runner.
- Returns
Nothing.
Prints a summary line to stdout (and to the output file if open) showing the total number of successful checks, failed checks, executed test cases, and test suites, 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 175 of file reporter-human.h, definition at line 202 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::colours_, micro_os_plus::micro_test_plus::detail::timestamps::compute_elapsed_time, micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests, micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks, micro_os_plus::micro_test_plus::reporter::flush, micro_os_plus::micro_test_plus::detail::timestamps::has_timestamps, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::silent, micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks, micro_os_plus::micro_test_plus::runner::timings, micro_os_plus::micro_test_plus::runner::total_suites_count, micro_os_plus::micro_test_plus::detail::test_node::totals, micro_os_plus::micro_test_plus::reporter::verbosity_ and micro_os_plus::micro_test_plus::detail::runner_totals::was_successful.
end_subtest()
| virtual |
Mark the end of a subtest.
- Parameters
-
subtest Reference to the subtest.
- Returns
Nothing.
This method marks the end of a test case, summarising its outcome and outputting the results with appropriate formatting and colour coding. If any checks have failed, a failure message is displayed, including the number of successful and failed checks. For passing test cases, a success message is shown with the total number of checks. The output is adjusted according to the verbosity level, and additional spacing is managed for clarity. The output buffer is cleared and the stream is flushed to ensure all results are immediately visible, supporting clear and organised reporting across all test cases and folders.
Declaration at line 215 of file reporter-human.h, definition at line 561 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::reporter::colours_, micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks, micro_os_plus::micro_test_plus::reporter::flush, micro_os_plus::micro_test_plus::indent, micro_os_plus::micro_test_plus::indent_size, micro_os_plus::micro_test_plus::detail::test_node::name, micro_os_plus::micro_test_plus::subtest::nesting_depth, micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks, micro_os_plus::micro_test_plus::detail::test_node::totals, micro_os_plus::micro_test_plus::verbose, micro_os_plus::micro_test_plus::reporter::verbosity_, micro_os_plus::micro_test_plus::detail::runner_totals::was_successful, micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_ and micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout.
end_suite()
| virtual |
Mark the end of a test suite.
- Parameters
-
suite Reference to the test suite.
- Returns
Nothing.
This method marks the end of a test suite, summarising the overall results and presenting them with appropriate formatting and colour coding. If the suite contains test cases and the verbosity is not set to quiet, an empty line is added for clarity. For suites with no failed checks and at least one successful check, a success message is displayed, including the number of checks and test cases. Otherwise, a failure message is shown, detailing the number of successful and failed checks, as well as the total number of test cases. The output is immediately flushed to ensure prompt and organised reporting across all test cases and folders.
Declaration at line 195 of file reporter-human.h, definition at line 352 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::add_empty_line_, micro_os_plus::micro_test_plus::reporter::buffer_, micro_os_plus::micro_test_plus::reporter::colours_, micro_os_plus::micro_test_plus::detail::timestamps::compute_elapsed_time, micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests, micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks, micro_os_plus::micro_test_plus::reporter::flush, micro_os_plus::micro_test_plus::detail::timestamps::has_timestamps, micro_os_plus::micro_test_plus::indent, micro_os_plus::micro_test_plus::indent_size, micro_os_plus::micro_test_plus::detail::test_node::name, micro_os_plus::micro_test_plus::normal, micro_os_plus::micro_test_plus::reporter::output_file_, micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks, micro_os_plus::micro_test_plus::suite::timings, micro_os_plus::micro_test_plus::detail::test_node::totals, micro_os_plus::micro_test_plus::verbose, micro_os_plus::micro_test_plus::reporter::verbosity_, micro_os_plus::micro_test_plus::detail::runner_totals::was_successful, micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_ and micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout.
endline()
|
Inserts a line ending into the output buffer.
- Parameters
None.
- Returns
Nothing.
This method appends a newline character to the internal output buffer of the reporter and immediately flushes the stream. This ensures that each line of test output is clearly separated and promptly displayed, enhancing the readability and organisation of test results across all test cases and folders.
Declaration at line 291 of file reporter.h, definition at line 221 of file reporter.cpp.
References micro_os_plus::micro_test_plus::reporter::buffer_ and micro_os_plus::micro_test_plus::reporter::flush.
Referenced by operator<<.
expression()
| inline |
Provides access to the expression formatter for this reporter.
- Parameters
None.
- Returns
Reference to the expression_formatter instance used by this reporter.
Returns a reference to the expression_formatter instance used by the reporter for formatting expressions in test reports. This allows the reporter to delegate the formatting of complex expressions to the expression_formatter, which provides a consistent and extensible way to convert various types of values and expressions into their string representations for output in test reports.
Declaration at line 451 of file reporter.h, definition at line 106 of file reporter-inlines.h.
Reference micro_os_plus::micro_test_plus::reporter::expression_.
Referenced by micro_os_plus::micro_test_plus::subtest::assume, micro_os_plus::micro_test_plus::subtest::expect, micro_os_plus::micro_test_plus::reporter::fail, micro_os_plus::micro_test_plus::reporter::get_comment_prefix, micro_os_plus::micro_test_plus::reporter::operator<< and micro_os_plus::micro_test_plus::reporter::pass.
fail()
|
Report a failed condition.
- Parameters
-
abort Whether to abort execution after failure.
message The message to display.
expression The string representation of the expression.
has_expression Whether the expression is a compound op to display.
location The source location of the failure.
subtest The subtest that owns this check.
- Returns
Nothing.
Reports a test failure, formatting the output with source location and, when has_expression is true, the pre-formatted expression string.
Declaration at line 349 of file reporter.h, definition at line 463 of file reporter.cpp.
References micro_os_plus::micro_test_plus::reporter::expression, micro_os_plus::micro_test_plus::reporter::output_fail_prefix_ and micro_os_plus::micro_test_plus::reporter::output_fail_suffix_.
flush()
|
Flush the current buffered content.
- Parameters
None.
- Returns
Nothing.
This method flushes the output buffer of the reporter by synchronising it with the standard output stream. This guarantees that all pending test output is immediately written and visible, ensuring prompt and reliable reporting of test results across all test cases and folders.
Declaration at line 318 of file reporter.h, definition at line 365 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::reporter::output_file_.
Referenced by begin_session, micro_os_plus::micro_test_plus::reporter_tap::begin_session, begin_subtest, micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, begin_suite, micro_os_plus::micro_test_plus::reporter_tap::begin_suite, end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session, end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite, micro_os_plus::micro_test_plus::reporter::endline, output_fail_suffix_, micro_os_plus::micro_test_plus::reporter_tap::output_fail_suffix_, output_pass_suffix_ and micro_os_plus::micro_test_plus::reporter_tap::output_pass_suffix_.
get_comment_prefix()
| 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 reporter does not prefix comment lines; the write_info_() output appears as plain text.
Declaration at line 226 of file reporter-human.h, definition at line 695 of file reporter-human.cpp.
Referenced by operator<<.
pass()
|
Report a passed condition.
- Parameters
-
message The message to display.
expression The string representation of the expression.
subtest The subtest 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 332 of file reporter.h, definition at line 444 of file reporter.cpp.
References micro_os_plus::micro_test_plus::reporter::expression, micro_os_plus::micro_test_plus::reporter::output_pass_prefix_ and micro_os_plus::micro_test_plus::reporter::output_pass_suffix_.
verbosity()
| inline |
Returns the current verbosity level.
- Parameters
None.
- Returns
The active verbosity value.
Returns the verbosity level stored in verbosity_.
Declaration at line 440 of file reporter.h, definition at line 91 of file reporter-inlines.h.
References micro_os_plus::micro_test_plus::reporter::verbosity and micro_os_plus::micro_test_plus::reporter::verbosity_.
Referenced by micro_os_plus::micro_test_plus::reporter::get_comment_prefix and micro_os_plus::micro_test_plus::reporter::verbosity.
write_buffer_to_stdout()
|
Output the current buffered content.
Public because deferred_reporter_base calls this from its destructor when aborting, after the subtest instance is no longer accessible via the normal reporting path.
- Parameters
None.
- Returns
Nothing.
This method writes the contents of the internal output buffer to the standard output stream without appending a newline character. After outputting the buffer, it is cleared to prepare for subsequent output. This approach ensures that test results are presented promptly and efficiently, supporting clear and organised reporting across all test cases and folders.
Declaration at line 307 of file reporter.h, definition at line 237 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::reporter::buffer_.
Referenced by micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite and micro_os_plus::micro_test_plus::reporter_tap::end_suite.
Protected Member Functions
colour_()
| inline nodiscard protected |
Selects the appropriate colour code based on a condition.
- Parameters
-
cond Boolean value indicating pass (true) or fail (false).
- Returns
The corresponding ANSI colour code as a string.
Returns the ANSI colour code for pass or fail, depending on the boolean condition provided.
Declaration at line 463 of file reporter.h, definition at line 117 of file reporter-inlines.h.
Reference micro_os_plus::micro_test_plus::reporter::colours_.
Referenced by micro_os_plus::micro_test_plus::reporter::get_comment_prefix.
output_fail_prefix_()
| protected 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.
subtest The subtest that owns this check.
- Returns
Nothing.
This method outputs the prefix for a failing check result, applying the appropriate colour formatting and symbols to clearly indicate failure. If the output occurs within a subtest, additional indentation is applied for readability. The prefix includes a cross symbol (✗), an optional message, and the label "FAILED". The source location is appended in parentheses, showing the file or folder name and line number where the failure occurred. Colour formatting is reset after the prefix to maintain consistent output style across all test cases and folders.
Declaration at line 262 of file reporter-human.h, definition at line 753 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::colours_, micro_os_plus::micro_test_plus::reflection::source_location::file_name, micro_os_plus::micro_test_plus::indent, micro_os_plus::micro_test_plus::reflection::source_location::line, micro_os_plus::micro_test_plus::subtest::nesting_depth and micro_os_plus::micro_test_plus::reflection::short_name.
output_fail_suffix_()
| protected virtual |
Outputs the suffix for a failing condition.
- Parameters
-
location The source location of the failure.
abort Whether to abort execution after failure.
subtest The subtest that owns this check.
- Returns
Nothing.
This method outputs the suffix for a failing check result by closing the location information, appending an "aborted..." message if the check was aborted, and then adding a newline to the output. The output stream is flushed to ensure immediate visibility. This approach guarantees that failure results are clearly separated, promptly reported, and easily distinguishable across all test cases and folders.
Declaration at line 276 of file reporter-human.h, definition at line 799 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::endl and micro_os_plus::micro_test_plus::reporter::flush.
output_pass_prefix_()
| protected virtual |
Outputs the prefix for a passing condition.
- Parameters
-
message The message to display.
subtest The subtest that owns this check.
- Returns
Nothing.
This method outputs the prefix for a passing check result, applying the appropriate colour formatting and symbols to clearly indicate success. If the output occurs within a subtest, additional indentation is applied for readability. The prefix includes a tick symbol (✓) and, if provided, an associated message. Colour formatting is reset after the prefix to maintain consistent output style across all test cases and folders.
The prefix/suffix methods help shorten the code generated by the template methods.
Declaration at line 238 of file reporter-human.h, definition at line 713 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::reporter::colours_, micro_os_plus::micro_test_plus::indent and micro_os_plus::micro_test_plus::subtest::nesting_depth.
output_pass_suffix_()
| protected virtual |
Outputs the suffix for a passing condition.
- Parameters
-
subtest The subtest that owns this check.
- Returns
Nothing.
Completes pass output by appending endl and flushing buffered content to the configured sinks.
The prefix/suffix methods help shorten the code generated by the template methods.
Declaration at line 248 of file reporter-human.h, definition at line 734 of file reporter-human.cpp.
References micro_os_plus::micro_test_plus::endl and micro_os_plus::micro_test_plus::reporter::flush.
write_buffer_to_file_()
| protected |
Writes the contents of buffer_ to output_file_ using fprintf without appending a newline. If output_file_ is null, the call is a no-op.
Declaration at line 466 of file reporter.h, definition at line 250 of file reporter.cpp.
References micro_os_plus::micro_test_plus::reporter::buffer_ and micro_os_plus::micro_test_plus::reporter::output_file_.
Referenced by end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite and micro_os_plus::micro_test_plus::reporter::get_comment_prefix.
write_info_()
| protected |
Appends informational (non-result) text to the output buffer.
- Parameters
None.
- Returns
Nothing.
Constructs and emits two informational lines: the first lists the programme name 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 unless verbosity is set to silent.
Declaration at line 477 of file reporter.h, definition at line 270 of file reporter.cpp.
Reference micro_os_plus::micro_test_plus::reporter::argvs_.
Referenced by begin_session, micro_os_plus::micro_test_plus::reporter_tap::begin_session and micro_os_plus::micro_test_plus::reporter::get_comment_prefix.
Protected Member Attributes
add_empty_line_
| protected |
Controls whether to add an empty line between successful test cases.
Used to nicely format the output.
Definition at line 572 of file reporter.h.
Referenced by begin_session, micro_os_plus::micro_test_plus::reporter_tap::begin_session, begin_subtest, micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, begin_suite, micro_os_plus::micro_test_plus::reporter_tap::begin_suite, end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session, end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite and micro_os_plus::micro_test_plus::reporter_tap::end_suite.
argvs_
| protected |
Owns the command-line arguments passed to the test runner.
Definition at line 596 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::reporter::reporter, operator<< and micro_os_plus::micro_test_plus::reporter::write_info_.
buffer_
| protected |
Output accumulation buffer.
Accumulates all reporter output until it is written to standard output or the output file via write_buffer_to_stdout() or write_buffer_to_file_().
Definition at line 552 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::reporter::reporter, begin_subtest, micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite, micro_os_plus::micro_test_plus::reporter::endline, micro_os_plus::micro_test_plus::reporter::operator<<, micro_os_plus::micro_test_plus::reporter::operator<<, micro_os_plus::micro_test_plus::reporter::operator<<, micro_os_plus::micro_test_plus::reporter::operator<<, micro_os_plus::micro_test_plus::reporter::operator<<, operator<<, micro_os_plus::micro_test_plus::reporter_tap::operator<<, micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_ and micro_os_plus::micro_test_plus::reporter::write_buffer_to_stdout.
colours_
| protected |
ANSI colour codes for output formatting.
Definition at line 542 of file reporter.h.
Referenced by reporter_human, micro_os_plus::micro_test_plus::reporter::colour_, end_session, end_subtest, end_suite, output_fail_prefix_ and output_pass_prefix_.
expression_
| protected |
Expression formatter for pass and fail reporting.
Used in pass() and fail() to format expression values before appending the result to buffer_. Will also be used by detail::deferred_reporter to pre-format expressions at construction time.
Definition at line 563 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::reporter::expression.
output_file_
| protected |
Optional output file for redirecting test report output.
When non-null, all output is written to this file instead of standard output. The reporter does not own the file; the caller is responsible for its lifetime.
Definition at line 591 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::reporter::reporter, micro_os_plus::micro_test_plus::reporter::~reporter, begin_session, micro_os_plus::micro_test_plus::reporter_tap::begin_session, begin_subtest, micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, begin_suite, micro_os_plus::micro_test_plus::reporter_tap::begin_suite, end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session, end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite, micro_os_plus::micro_test_plus::reporter::flush and micro_os_plus::micro_test_plus::reporter::write_buffer_to_file_.
output_file_path_
| protected |
Optional file path for redirecting test report output.
When non-null, write_buffer_to_file_() writes accumulated output to this path in addition to (or instead of) standard output.
Definition at line 581 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::reporter::reporter and micro_os_plus::micro_test_plus::reporter::~reporter.
verbosity_
| protected |
The verbosity level for test reporting.
Definition at line 537 of file reporter.h.
Referenced by micro_os_plus::micro_test_plus::reporter::reporter, begin_session, micro_os_plus::micro_test_plus::reporter_tap::begin_session, begin_subtest, micro_os_plus::micro_test_plus::reporter_tap::begin_subtest, begin_suite, micro_os_plus::micro_test_plus::reporter_tap::begin_suite, end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session, end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite and micro_os_plus::micro_test_plus::reporter::verbosity.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.