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