TestRunner
TestRunner
#include <icy/test.h>Test manager queue.
The [TestRunner](#testrunner) is a queue in charge of running one or many tests.
When [run()](#run-10) the [TestRunner](#testrunner) loops through each test in the list calling the test's [run()](#run-10) method.
Public Methods
| Return | Name | Description |
|---|---|---|
TestRunner | ||
void | add | Adds a test to the runner and prints its name to stdout. |
Test * | get const | Return a pointer to the test matching the given name, or nullptr if no matching test exists. |
void | run | Runs all registered tests sequentially, printing results to stdout. |
void | clear | Destroy and clears all managed tests. |
Test * | current const | Return the currently active Test or nullptr. |
TestList | tests const | Return the list of tests. |
ErrorMap | errors const | Return a map of tests and errors. |
bool | passed const | Return true if all tests passed. |
TestRunner
TestRunner()add
void add(Test * test)Adds a test to the runner and prints its name to stdout.
Parameters
testNon-null pointer to the test; the runner takes ownership.
get
const
Test * get(std::string_view name) constReturn a pointer to the test matching the given name, or nullptr if no matching test exists.
Parameters
nameTest name to search for.
Returns
Matching test pointer or nullptr.
run
void run()Runs all registered tests sequentially, printing results to stdout.
clear
void clear()Destroy and clears all managed tests.
current
const
Test * current() constReturn the currently active Test or nullptr.
tests
const
TestList tests() constReturn the list of tests.
errors
const
ErrorMap errors() constReturn a map of tests and errors.
passed
const
bool passed() constReturn true if all tests passed.
Public Static Methods
| Return | Name | Description |
|---|---|---|
TestRunner & | getDefault static | Return the default [TestRunner](#testrunner) singleton, although [TestRunner](#testrunner) instances may also be initialized individually. |
getDefault
static
static TestRunner & getDefault()Return the default [TestRunner](#testrunner) singleton, although [TestRunner](#testrunner) instances may also be initialized individually.
Protected Attributes
_mutex
std::mutex _mutex_tests
TestList _tests_current
Test * _current