18 #include <cppunit/BriefTestProgressListener.h> 19 #include <cppunit/CompilerOutputter.h> 20 #include <cppunit/TestResult.h> 21 #include <cppunit/TestResultCollector.h> 22 #include <cppunit/TestRunner.h> 23 #include <cppunit/XmlOutputter.h> 24 #include <cppunit/extensions/TestFactoryRegistry.h> 40 int main(
int argc,
char* argv[])
44 string testPath = (argc > 1) ?
string(argv[1]) : string(
"");
47 CPPUNIT_NS::TestResult controller;
50 CPPUNIT_NS::TestResultCollector result;
51 controller.addListener(&result);
54 CPPUNIT_NS::BriefTestProgressListener progress;
55 controller.addListener(&progress);
58 CPPUNIT_NS::TestRunner runner;
59 runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
63 CPPUNIT_NS::stdCOut() <<
"Running " << (testPath.empty() ?
"all tests" : testPath) << endl;
64 runner.run(controller, testPath);
65 CPPUNIT_NS::stdCOut() << endl;
68 CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
72 ofstream file(
"libcpp-Tests-Results.xml");
73 CPPUNIT_NS::XmlOutputter xml(&result, file);
76 }
catch (invalid_argument& e)
78 CPPUNIT_NS::stdCOut() << endl <<
"ERROR: " << e.what() << endl;
82 return result.wasSuccessful() ? 0 : 1;
int main(int argc, char *argv[])