Generic test runner.
The TestRunner assumes ownership of all added tests: you can not add test or suite that are local variable since they can't be deleted.
Example of usage:
int
main( int argc, char* argv[] )
{
std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
controller.addListener( &result );
CppUnit::TextTestProgressListener progress;
controller.addListener( &progress );
runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
try
{
std::cout << "Running " << testPath;
runner.run( controller, testPath );
std::cerr << std::endl;
CppUnit::CompilerOutputter outputter( &result, std::cerr );
outputter.write();
}
catch ( std::invalid_argument &e )
{
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
return 0;
}
return result.wasSuccessful() ? 0 : 1;
}