Class Output

Inheritance Relationships

Derived Types

Class Documentation

class Output
[source]

Abstract base class for all test output sinks.

Implement print_buffer() in a subclass to direct output anywhere. All higher-level printing methods (print_failure(), print_test_run(), etc.) are built on top of print_buffer(). The static function pointers (stdout_, fopen_, fputs_, fclose_) allow ConsoleOutput to redirect file I/O without a virtual dispatch.

Subclassed by mu::tiny::test::ConsoleOutput, mu::tiny::test::StringBufferOutput

Public Types

enum class MutinyVerbosityLevel

Controls how much detail is printed per test.

Values:

enumerator quiet

Only failures and the summary line.

enumerator verbose

One line per test.

enumerator very_verbose

Full per-test detail including test properties.

using File = void*

Replaceable stdout handle used by ConsoleOutput.

using FOpenFunc = File (*)(const char *filename, const char *flag)

Replaceable fopen function used by ConsoleOutput.

using FPutsFunc = void (*)(const char *str, File file)

Replaceable fputs function used by ConsoleOutput.

using FCloseFunc = void (*)(File file)

Replaceable fclose function used by ConsoleOutput.

Public Functions

explicit Output() = default
[source]
virtual ~Output() = default
[source]
virtual void print_tests_started()
[source]

Called once before any tests run.

virtual void print_tests_ended(const Result &result)

Called once after all tests have run.

Parameters:

result – The final result summary.

virtual void print_current_test_started(const Shell &test)

Called before each test body begins.

Parameters:

test – The test about to run.

virtual void print_current_test_ended(const Result &res)

Called after each test body completes.

Parameters:

res – The result state at the end of the test.

virtual void print_current_group_started(const Shell &test)

Called when execution enters a new test group.

Parameters:

test – A test from the group that is starting.

virtual void print_current_group_ended(const Result &res)

Called when execution leaves a test group.

Parameters:

res – The result state at the end of the group.

virtual void verbose(MutinyVerbosityLevel level)

Set the verbosity level.

Parameters:

level – Desired verbosity.

virtual void color()
[source]

Enable coloured output.

virtual void print_buffer(const char *s) = 0

Write s directly to the underlying output medium.

This is the only pure-virtual method; all other print methods call it.

Parameters:

s – Null-terminated string to write.

virtual void print(const char *s)

Print a null-terminated string.

Parameters:

sString to print.

virtual void print(int n)

Print a signed integer.

Parameters:

n – Value to print.

virtual void print(unsigned int n)

Print an unsigned integer.

Parameters:

n – Value to print.

virtual void print(long n)

Print a signed integer.

Parameters:

n – Value to print.

virtual void print(double d)

Print a floating-point value.

Parameters:

d – Value to print.

virtual void print_failure(const Failure &failure)

Print a test failure message.

Parameters:

failure – The failure to describe.

virtual void print_test_property(const char *name, const char *value)

Print a test property key/value pair.

Parameters:
  • name – Property name.

  • value – Property value.

virtual void print_skipped(const char *message)

Mark the current test as skipped.

Parameters:

message – Human-readable reason (may be empty).

virtual void print_test_run(unsigned int number, unsigned int total)

Print the current repetition progress.

Parameters:
  • number – Current repetition (1-based).

  • total – Total number of repetitions.

virtual void set_progress_indicator(const char *indicator)

Override the per-test progress indicator character.

Parameters:

indicator – Null-terminated indicator string (default: .).

virtual void print_very_verbose(const char *s)

Print a very-verbose detail line.

Parameters:

s – Detail string to print.

inline virtual bool needs_console_companion() const
Returns:

true if this output needs a ConsoleOutput companion for interactive output (e.g. JUnitOutputPlugin paired with a console).

inline virtual void flush()
[source]

Flush any buffered output.

Public Static Attributes

static File stdout_
static FOpenFunc fopen_
static FPutsFunc fputs_
static FCloseFunc fclose_

Protected Functions

virtual void print_progress_indicator()
[source]
void print_file_and_line_for_test_and_failure(const Failure &failure)
void print_file_and_line_for_failure(const Failure &failure)
void print_failure_in_test(const String &test_name)
void print_failure_message(const String &reason)
void print_error_in_file_on_line_formatted_for_working_environment(const String &test_file, int_least32_t line_number)
Output(const Output&)
Output &operator=(const Output&)

Protected Attributes

int dot_count_ = {0}
MutinyVerbosityLevel verbose_ = {MutinyVerbosityLevel::quiet}
bool color_ = {false}
const char *progress_indication_ = {"."}