Class CommandLineRunner¶
Defined in File CommandLineRunner.hpp
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.
registry – Registry of tests to run; must outlive this object.
Public Static Functions
-
static int run_all_tests(int argc, const char *const *argv)¶
Parse
argvand run all registered tests; return a process exit code.This overload accepts
constchar* const* and is suitable for use with main() signatures that takeconstargv.- 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
argvand run all registered tests; return a process exit code.Overload for the common
intmain(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
plugininto the current registry before running tests.Equivalent to
but does not require including mu/tiny/test/Registry.hpp. Call this before run_all_tests().Registry::get_current_registry()->install_plugin(&plugin);
- Parameters:
plugin – Plugin 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.
-
CommandLineRunner(int argc, const char *const *argv, Registry *registry)¶