Base module

TestRunner

[Test]({#ref classicy_1_1test_1_1Test #}) manager queue.

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

ReturnNameDescription
TestRunner
voidaddAdds a test to the runner and prints its name to stdout.
Test *get constReturn a pointer to the test matching the given name, or nullptr if no matching test exists.
voidrunRuns all registered tests sequentially, printing results to stdout.
voidclearDestroy and clears all managed tests.
Test *current constReturn the currently active Test or nullptr.
TestListtests constReturn the list of tests.
ErrorMaperrors constReturn a map of tests and errors.
boolpassed constReturn 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

  • test Non-null pointer to the test; the runner takes ownership.

get

const

Test * get(std::string_view name) const

Return a pointer to the test matching the given name, or nullptr if no matching test exists.

Parameters

  • name Test 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() const

Return the currently active Test or nullptr.


tests

const

TestList tests() const

Return the list of tests.


errors

const

ErrorMap errors() const

Return a map of tests and errors.


passed

const

bool passed() const

Return true if all tests passed.

Public Static Methods

ReturnNameDescription
TestRunner &getDefault staticReturn 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

ReturnNameDescription
std::mutex_mutex
TestList_tests
Test *_current

_mutex

std::mutex _mutex

_tests

TestList _tests

_current

Test * _current