I am using CppUnit as a unit test framework. Is it possible to select a subset of testcases to execute at runtime?
Is there a filtering option provided within CppUn
An alternative approach:
// find the unit test as specified by the one argument to this program
CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
int iTestIndex = 0;
for (; iTestIndex < suite->getChildTestCount(); ++iTestIndex)
{
fprintf(stderr, "INFO: Looking for a match between '%s' and '%s'\n",
suite->getChildTestAt(iTestIndex)->getName().c_str(),
argv[1]);
if (suite->getChildTestAt(iTestIndex)->getName() == std::string(argv[1]))
{
fprintf(stderr, "INFO: Found a match for '%s' and '%s'\n",
suite->getChildTestAt(iTestIndex)->getName().c_str(),
argv[1]);
break;
}
}
if (iTestIndex >= suite->getChildTestCount())
{
fprintf(stderr, "ERROR: Did NOT find test '%s'!\n", argv[1]);
return -1;
}