Home
Base module

TestRunner

Test manager queue.

TestRunner

#include <icy/test.h>
class TestRunner

Defined in src/base/include/icy/test.h:148

Test manager queue.

The [TestRunner](#testrunner-1) is a queue in charge of running one or many tests.

When [run()](#run-10) the [TestRunner](#testrunner-1) loops through each test in the list calling the test's [run()](#run-10) method.

List of all members

NameKindOwner
TestRunnerfunctionDeclared here
~TestRunnerfunctionDeclared here
addfunctionDeclared here
getfunctionDeclared here
runfunctionDeclared here
clearfunctionDeclared here
currentfunctionDeclared here
testsfunctionDeclared here
errorsfunctionDeclared here
passedfunctionDeclared here
getDefaultfunctionDeclared here
_mutexvariableDeclared here
_testsvariableDeclared here
_currentvariableDeclared here

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()

Defined in src/base/include/icy/test.h:151


add

void add(Test * test)

Defined in src/base/include/icy/test.h:156

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

Defined in src/base/include/icy/test.h:162

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()

Defined in src/base/include/icy/test.h:165

Runs all registered tests sequentially, printing results to stdout.


clear

void clear()

Defined in src/base/include/icy/test.h:168

Destroy and clears all managed tests.


current

const

Test * current() const

Defined in src/base/include/icy/test.h:171

Return the currently active Test or nullptr.


tests

const

TestList tests() const

Defined in src/base/include/icy/test.h:174

Return the list of tests.


errors

const

ErrorMap errors() const

Defined in src/base/include/icy/test.h:177

Return a map of tests and errors.


passed

const

bool passed() const

Defined in src/base/include/icy/test.h:180

Return true if all tests passed.

Public Static Methods

ReturnNameDescription
TestRunner &getDefault staticReturn the default [TestRunner](#testrunner-1) singleton, although [TestRunner](#testrunner-1) instances may also be initialized individually.

getDefault

static

static TestRunner & getDefault()

Defined in src/base/include/icy/test.h:184

Return the default [TestRunner](#testrunner-1) singleton, although [TestRunner](#testrunner-1) instances may also be initialized individually.

Protected Attributes

ReturnNameDescription
std::mutex_mutex
TestList_tests
Test *_current

_mutex

std::mutex _mutex

Defined in src/base/include/icy/test.h:187


_tests

TestList _tests

Defined in src/base/include/icy/test.h:188


_current

Test * _current

Defined in src/base/include/icy/test.h:189