To use this class, you must add tests to the test suite and then call run(). A class template called TestCase is provided to simplify writing your own test cases. Just create an explicit specialization of runTest() for each test number T and add that test to the test suite. For example:
{
}
{
}
void runTest() override
Definition: testcommon.h:1006
Then in your main function, add each test to the test suite and run the whole test suite. It is not necessary to make the test numbers used for the template parameter be the same as the test number for it in the suite itself. The test suite assigns its own name and number to each test case when run() is called. The tests can be added one at a time like this:
int main(
int argc,
char* argv[])
{
return suite.run();
}
Nested class template defining a test case for test TestNum.
Definition: testcommon.h:1001
Class for implementing a suite of related tests.
Definition: testcommon.h:851
int main(int argc, char **argv)
Definition: wsscheduler_mongodb.cpp:81
Or you can add the whole set of test cases in one go using the addTestCases() function:
int main(
int argc,
char* argv[])
{
suite.addTestCases<4>();
return suite.run();
}
Any test case for which a specialized runTest() is not provided will be treated as skipped, so for TestCase<4> in the first example above, that particular case will get treated as skipped. In the second example, cases 2 and 4 are both skipped as well but if a runTest() specialization is ever provided for that case, it will automatically be included.
As a general guide, unless you have more than 17 test cases for the test suite, prefer to use addTestCases() because it is easier to maintain.