#include "cppunit/extensions/TestFactoryRegistry.h" #include "cppunit/CompilerOutputter.h" #include "cppunit/TestResult.h" #include "cppunit/TestResultCollector.h" #include "cppunit/TestRunner.h" #include "cppunit/TextTestProgressListener.h" using namespace std; using namespace CppUnit; /** * @author Keith Lee * keithlee [ at ] unc.edu */ int main( int argc, char* argv[] ) { string testPath = ( argc > 1 ) ? string( argv[1] ) : ""; //Create the event manager and test controller TestResult controller; //Add a listener that collects test results TestResultCollector result; controller.addListener( &result ); //Add a listener that prints dots as tests run TextTestProgressListener progress; controller.addListener( &progress ); //Add the top suite to the test runner TestRunner runner; runner.addTest( TestFactoryRegistry::getRegistry().makeTest() ); //Run the test cout << "" << testPath; runner.run( controller, testPath ); cerr << endl; //Print test in a compiler compatible format CompilerOutputter outputter( &result, cerr ); outputter.write(); return result.wasSuccessful() ? 0 : 1; }