Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
JonTest::TestRunner Class Reference

Singleton that collects all TEST_SUITE()s, to run on demand. More...

#include <TestRunner.h>

Collaboration diagram for JonTest::TestRunner:
Collaboration graph

Public Types

typedef std::vector< std::string > TestNames
 List of Test Names as: "<suite>" or "<suite>:<case>".
 

Public Member Functions

void add (const char *const name, TestSuiteInterface *const suite)
 Add the suite by name.
 
bool isValid (const std::string &test) const
 Determine if test can be run as one of: a valid Test Suite, or Test Suite:Test Case.
 
void listTestSuites (std::ostream &out) const
 List available Test Suites to out.
 
void listTestCases (std::ostream &out) const
 List available Test Cases to out.
 
Count run (Logger &logger) const
 Run all tests that have been add()ed.
 
Count run (Logger &logger, const TestNames &tests) const
 Run the specified tests.
 

Static Public Member Functions

static TestRunnerget ()
 Get the singleton.
 

Private Member Functions

 TestRunner ()=default
 

Private Attributes

std::map< std::string, TestSuiteInterface * > suites
 Mapping of test suite name to test suite.
 

Detailed Description

Singleton that collects all TEST_SUITE()s, to run on demand.

Definition at line 19 of file TestRunner.h.

Member Typedef Documentation

◆ TestNames

typedef std::vector<std::string> JonTest::TestRunner::TestNames

List of Test Names as: "<suite>" or "<suite>:<case>".

Definition at line 30 of file TestRunner.h.

Constructor & Destructor Documentation

◆ TestRunner()

JonTest::TestRunner::TestRunner ( )
privatedefault

Member Function Documentation

◆ add()

void JonTest::TestRunner::add ( const char *const  name,
TestSuiteInterface *const  suite 
)

Add the suite by name.

Parameters
nameName of suite
suiteTest Suite

Definition at line 60 of file TestRunner.cpp.

◆ get()

TestRunner & JonTest::TestRunner::get ( )
static

Get the singleton.

Returns
the singleton.
Examples
SimpleTest.cpp, TestCaseOrder.cpp, and main.cpp.

Definition at line 54 of file TestRunner.cpp.

◆ isValid()

bool JonTest::TestRunner::isValid ( const std::string &  test) const

Determine if test can be run as one of: a valid Test Suite, or Test Suite:Test Case.

Returns
true if test can be run, otherwise false

Definition at line 69 of file TestRunner.cpp.

◆ listTestCases()

void JonTest::TestRunner::listTestCases ( std::ostream &  out) const

List available Test Cases to out.

Examples
main.cpp.

Definition at line 114 of file TestRunner.cpp.

◆ listTestSuites()

void JonTest::TestRunner::listTestSuites ( std::ostream &  out) const

List available Test Suites to out.

Examples
main.cpp.

Definition at line 95 of file TestRunner.cpp.

◆ run() [1/2]

Count JonTest::TestRunner::run ( Logger logger) const

Run all tests that have been add()ed.

<

Returns
Count of tests run and tests failed fails.
Parameters
loggerTo report status to
Examples
SimpleTest.cpp, TestCaseOrder.cpp, and main.cpp.

Definition at line 142 of file TestRunner.cpp.

◆ run() [2/2]

Count JonTest::TestRunner::run ( Logger logger,
const TestNames tests 
) const

Run the specified tests.

Any element of tests that fails isValid(test) will be reported as an error and test failure.

Returns
Count of tests run and tests failed fails. <
Count of tests run and tests failed fails.
Parameters
loggerTo report status to
testsTo run

Definition at line 158 of file TestRunner.cpp.

Member Data Documentation

◆ suites

std::map<std::string, TestSuiteInterface*> JonTest::TestRunner::suites
private

Mapping of test suite name to test suite.

Definition at line 23 of file TestRunner.h.


The documentation for this class was generated from the following files: