Class CommandLineRunner

Class Documentation

class CommandLineRunner
[source]

Parses command-line arguments and drives the test run.

Construct one, then call run_all_tests_main(), or use the static helper run_all_tests() which does both in one call. Subclass and override create_console_output() or create_composite_output() to supply a custom output formatter.

Public Functions

CommandLineRunner(int argc, const char *const *argv, Registry *registry)

Construct a runner bound to a specific registry.

Prefer the static run_all_tests() helpers unless you need to supply a custom Registry (e.g. in framework self-tests).

Parameters:
  • argc – Argument count.

  • argv – Argument vector.

  • registryRegistry of tests to run; must outlive this object.

virtual ~CommandLineRunner()
[source]
int run_all_tests_main()
[source]

Parse arguments and run the tests registered in this runner’s registry.

Returns:

0 if all tests passed, non-zero otherwise.

Public Static Functions

static int run_all_tests(int argc, const char *const *argv)

Parse argv and run all registered tests; return a process exit code.

This overload accepts const char* const* and is suitable for use with main() signatures that take const argv.

Parameters:
  • argc – Argument count from main().

  • argv – Argument vector from main().

Returns:

0 if all tests passed, non-zero otherwise.

static int run_all_tests(int argc, char **argv)

Parse argv and run all registered tests; return a process exit code.

Overload for the common int main(int argc, char** argv) signature.

Parameters:
  • argc – Argument count from main().

  • argv – Argument vector from main().

Returns:

0 if all tests passed, non-zero otherwise.

static void install_plugin(Plugin &plugin)

Install plugin into the current registry before running tests.

Equivalent to

Registry::get_current_registry()->install_plugin(&plugin);
but does not require including mu/tiny/test/Registry.hpp. Call this before run_all_tests().

Parameters:

pluginPlugin to install; must outlive the test run.

Protected Functions

virtual Output *create_console_output()
[source]

Factory: create the console Output object. Override to replace it.

virtual Output *create_composite_output(Output *output_one, Output *output_two)

Factory: combine two outputs into a composite output.

Called when both console and file output are active simultaneously.

Parameters:
  • output_one – First output sink.

  • output_two – Second output sink.

Returns:

A composite Output that writes to both.

Protected Attributes

Output *output_ = {nullptr}

The active output object (owned by this runner).