45 #include <condition_variable>
100 std::map< std::string, std::map< std::string, TestCaseFactory *> >
tests;
106 std::map< std::string, ScenarioResults * >
results;
163 void getTestCases(
csr scenarioName, std::set< std::string > &testCases );
250 const std::string &
id() {
return mId; }
543 bool test(
bool cond,
csr testMsg,
bool expected =
false );
615 virtual bool runTest();
~DefaultScenario()
Destructor.
Definition: testmgr.h:486
std::map< std::string, ScenarioResults * > results
Results for scenario tests indexed by scenario name.
Definition: testmgr.h:106
DefaultScenario()
Constructor.
Definition: testmgr.h:483
AbstractTestCase * make(csr nm)
Create a test case object.
Definition: testmgr.h:522
cfi::logstream & log()
Get a reference to the logging stream used for the testing.
Definition: testmgr.cpp:79
A stream class specialized for logging.
Definition: log.h:58
ScenarioResults * scenario
Results for the scenario are placed in here.
Definition: testmgr.h:554
int mNumErrors
number of errors reported
Definition: testmgr.h:412
AsyncTestCase(csr name)
Constructor.
Definition: testmgr.cpp:353
void testScenario(csr scenario, ScenarioFactory *scn)
Do testing of a scenario.
Definition: testmgr.cpp:152
bool failed
Flag to hold overall testing result.
Definition: testmgr.h:95
std::string name
The name of the test case.
Definition: testmgr.h:534
static void event(csr id)
Create a TestEvent, queue it, and wait for it to be processed.
Definition: testmgr.cpp:448
virtual AbstractScenario * make(csr name)=0
Create an scenario object.
Provide a default scenario object.
Definition: testmgr.h:476
void getTestCases(csr scenarioName, std::set< std::string > &testCases)
Get the test case names for a scenario.
Definition: testmgr.cpp:95
static void install(csr nm, csr scn)
Install the factory for the test case.
Definition: testmgr.h:676
std::set< std::string > runningEvents
The set of events being handled.
Definition: testmgr.h:268
Responsible for installing a factory for making test objects.
Definition: testmgr.h:347
Responsible for creating a test case of some type.
Definition: testmgr.h:514
AbstractScenario(csr name)
Constructor.
Definition: testmgr.h:435
bool failure
true if scenario tests failed
Definition: testmgr.h:413
DefaultTest()
Default constructor that does nothing.
Definition: testmgr.h:365
virtual bool operator()(ScenarioResults *)
Execute the tests.
Definition: testmgr.cpp:320
Interface between applications and the test harness.
AsyncTestCaseT(csr nm)
Constructor.
Definition: testmgr.h:669
virtual void runTests(csr scenarioName, ScenarioResults *)
Runs the tests within the scenario.
Definition: testmgr.h:445
std::string scenarioName
The name of the scenario, as used when installed.
Definition: testmgr.h:429
bool done
This should be set by the handleEvent function.
Definition: testmgr.h:644
There is a problem but the program can continue.
Definition: sx.h:54
~TestEventQueue()
Destructor.
Definition: testmgr.cpp:443
AbstractScenario * make(csr name)
Create a scenario object.
Definition: testmgr.h:402
static void install(csr nm)
Install a scenario factor into the Tester.
Definition: testmgr.h:466
AbstractScenario * absScenario
Pointer to the abstract scenario object. Only valid during the test run.
Definition: testmgr.h:115
Responsible for creating a scenario of some type.
Definition: testmgr.h:395
Define a type for scenario factories.
Definition: testmgr.h:377
Define a base type for test case factories.
Definition: testmgr.h:495
static TestEventQueue & instance()
Get reference to the singleton queue object.
Definition: testmgr.cpp:430
AbstractTest * absTest
Pointer to the abstract test object. Only valid during the test run.
Definition: testmgr.h:112
csr getTestName()
Get the name of the test.
Definition: testmgr.h:134
Provide a default version of the AbstractTest object.
Definition: testmgr.h:361
static void install()
Install a factory for a type of AbstractTest object.
Definition: testmgr.h:351
static Tester & instance()
Get a reference to the Tester.
Definition: testmgr.cpp:62
void configure(csr testName)
specify the name of the test as in the configuration file
Definition: testmgr.cpp:45
int mNumTests
total number of tests
Definition: testmgr.h:411
AbstractTest * getTest()
Get the test object.
Definition: testmgr.h:182
virtual void runTests()
Run all the tests.
Definition: testmgr.cpp:229
ScenarioT(csr name)
Constructor.
Definition: testmgr.h:460
An exception object with severity levels.
Definition: sx.h:79
virtual ~Tester()
Destructor.
Definition: testmgr.h:143
TestEventQueue()
Constructor.
Definition: testmgr.cpp:438
Responsible for creating a test object of the required type.
Definition: testmgr.h:320
virtual ~AbstractScenario()
Destructor.
Definition: testmgr.h:438
throw this to abandon a particular test case
Definition: testmgr.h:206
std::mutex eventMx
Control access to the queue.
Definition: testmgr.h:266
Responsible for managing the testing.
Definition: testmgr.h:89
ScenarioFactory()
Constructor.
Definition: testmgr.h:381
Responsible for installing the factory for the test case type.
Definition: testmgr.h:662
Responsible for managing resources needed for the entire test.
Definition: testmgr.h:335
AbstractTest * make()
Construct a Test object.
Definition: testmgr.h:327
virtual AbstractTest * make()=0
Create an instance of the test object.
std::list< TestEvent * > events
The queue.
Definition: testmgr.h:267
std::chrono::steady_clock::duration timeOut
The time to wait. The default is 10 seconds.
Definition: testmgr.h:650
ScenarioResults()
Constructor.
Definition: testmgr.h:416
void setTest(TestFactory *t)
Set the main test object factory.
Definition: testmgr.h:176
virtual void handleEvent(TestEvent *ev)=0
Handle the events.
static void install(csr nm, csr scn)
Install a factory for the test case.
Definition: testmgr.h:599
TestFactory * theTest
Factor for the overall test.
Definition: testmgr.h:109
void addTestCase(csr name, csr scenario, TestCaseFactory *tcf)
Add a test case factory.
Definition: testmgr.cpp:87
Responsible for handling asynchronous tests.
Definition: testmgr.h:611
bool test(bool cond, csr testMsg, bool expected=false)
Perform or record a test.
Definition: testmgr.cpp:330
Responsible for storing the results of testing for a scenario.
Definition: testmgr.h:409
std::mutex functionsMx
Control access to list of running events.
Definition: testmgr.h:269
void title()
Print title for the test.
Definition: testmgr.cpp:262
virtual ~AbstractTest()
Destructor.
Definition: testmgr.h:339
void enqueueEvent(TestEvent *)
Place the event on the queue.
Definition: testmgr.cpp:466
virtual ~TestFactory()
Destructor.
Definition: testmgr.h:306
std::condition_variable eventCV
Wait for event to be queued or processed.
Definition: testmgr.h:270
std::chrono::steady_clock::time_point startTime
The time when the test is started.
Definition: testmgr.h:647
virtual AbstractTestCase * make(csr nm)=0
Create an instance of the test case object.
Responsible for installing a factory for the test case.
Definition: testmgr.h:585
test_exception()
Constructor.
Definition: testmgr.h:210
~DefaultTest()
Destructor.
Definition: testmgr.h:368
static const bool EXPECTED
Value for expected parameter of test()
Definition: testmgr.h:577
std::map< std::string, std::map< std::string, TestCaseFactory * > > tests
Factories for test cases indexed by name and scenario name.
Definition: testmgr.h:100
virtual ~AbstractTestCase()
Destructor.
Definition: testmgr.h:568
AbstractTestCase(csr nm)
Constructor.
Definition: testmgr.h:562
Represent an event in the object under test.
Definition: testmgr.h:235
virtual bool willRunTests()
Definition: testmgr.h:442
throw this to abandon an entire scenario
Definition: testmgr.h:217
TestCaseT(csr nm)
Constructor.
Definition: testmgr.h:592
const std::string & csr
Save some time typing and shorten parameter lines.
Definition: stringy.h:35
bool summary()
Print a summary of the testing to the log stream.
Definition: testmgr.cpp:275
Responsible for queuing TestEvents.
Definition: testmgr.h:259
Define a type for scenarios.
Definition: testmgr.h:425
Responsible for installing a factory to create scenarios of the required type.
Definition: testmgr.h:453
scenario_exception()
Constructor.
Definition: testmgr.h:221
void(* AsyncTestEventFn)(const std::string &s)
Pointer to function used to enqueue a test event.
Definition: test.h:42
virtual void timedOut()=0
Handle time out.
virtual void initTest()=0
Initiate the test case.
Tester()
Protected Constructor.
Definition: testmgr.cpp:70
TestEvent(const std::string &s)
Constructor.
Definition: testmgr.h:244
Declarations for the logging component of libcfi.
Responsible for creating an object that manages the resources for the entire test.
Definition: testmgr.h:302
std::string logName
Identifier for the log.
Definition: testmgr.h:94
void installDefaults()
Install default test and scenario objects.
Definition: testmgr.cpp:208
virtual ~TestCaseFactory()
Destructor.
Definition: testmgr.h:499
std::map< std::string, ScenarioFactory * > scenarios
Factories for scenarios indexed by scenario name.
Definition: testmgr.h:103
AbstractScenario * getScenario()
Get the current scenario object.
Definition: testmgr.h:188
An exception object with stream semantics.
std::string nameOfTest
Identifier for test in the configuration file.
Definition: testmgr.h:93
DefaultScenario(csr name)
Constructor.
Definition: testmgr.h:480
Base class for test cases.
Definition: testmgr.h:530
virtual bool runTest()=0
Run the tests for the test case.
virtual ~ScenarioFactory()
Destructor.
Definition: testmgr.h:384
void runTestCase(csr scenarioName, csr testCaseName, ScenarioResults *)
Run a specific test case.
Definition: testmgr.cpp:122
const std::string & id()
Get the identity of the event.
Definition: testmgr.h:250
void addScenario(csr scenario, ScenarioFactory *sf)
Add a scenario factory.
Definition: testmgr.cpp:106