Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
TestRunner.h
Go to the documentation of this file.
1#ifndef JON_TEST_TEST_RUNNER_H
2#define JON_TEST_TEST_RUNNER_H
3
4#include "JonTest/Count.h"
5
6#include <map>
7#include <ostream>
8#include <string>
9#include <vector>
10
11namespace JonTest
12{
13
14class Logger;
15class TestSuiteInterface;
16
20{
21private:
23 std::map<std::string, TestSuiteInterface*> suites;
24
25 // Private default constructor for singleton
26 TestRunner() = default;
27
28public:
30 typedef std::vector<std::string> TestNames;
31
36 static TestRunner& get();
37
40 void add(
41 const char* const name,
42 TestSuiteInterface* const suite
43 );
44
48 bool
49 isValid(
50 const std::string& test
51 ) const;
52
55 void listTestSuites(
56 std::ostream& out
57 ) const;
58
61 void listTestCases(
62 std::ostream& out
63 ) const;
64
67 Count
68 run(
69 Logger& logger
70 ) const;
71
79 Count
80 run(
81 Logger& logger,
82 const TestNames& tests
83 ) const;
84};
85
86}
87
88#endif
Count of tests run, and fails.
Definition Count.h:10
Interface for logging events while running tests.
Definition Logger.h:18
Singleton that collects all TEST_SUITE()s, to run on demand.
Definition TestRunner.h:20
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.
std::vector< std::string > TestNames
List of Test Names as: "<suite>" or "<suite>:<case>".
Definition TestRunner.h:30
Count run(Logger &logger) const
Run all tests that have been add()ed.
void listTestSuites(std::ostream &out) const
List available Test Suites to out.
void add(const char *const name, TestSuiteInterface *const suite)
Add the suite by name.
static TestRunner & get()
Get the singleton.
void listTestCases(std::ostream &out) const
List available Test Cases to out.
std::map< std::string, TestSuiteInterface * > suites
Mapping of test suite name to test suite.
Definition TestRunner.h:23
Interface for Test Suites.
Definition Count.h:5