7 #include <cppunit/BriefTestProgressListener.h>
8 #include <cppunit/CompilerOutputter.h>
9 #include <cppunit/TestResult.h>
10 #include <cppunit/TestResultCollector.h>
11 #include <cppunit/TestRunner.h>
12 #include <cppunit/XmlOutputter.h>
13 #include <cppunit/extensions/TestFactoryRegistry.h>
29 int main(
int argc,
char* argv[])
33 string testPath = (argc > 1) ?
string(argv[1]) : string(
"");
36 CPPUNIT_NS::TestResult controller;
39 CPPUNIT_NS::TestResultCollector result;
40 controller.addListener(&result);
43 CPPUNIT_NS::BriefTestProgressListener progress;
44 controller.addListener(&progress);
47 CPPUNIT_NS::TestRunner runner;
48 runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
52 CPPUNIT_NS::stdCOut() <<
"Running " << (testPath.empty() ?
"all tests" : testPath) << endl;
53 runner.run(controller, testPath);
54 CPPUNIT_NS::stdCOut() << endl;
57 CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
61 ofstream file(
"libcpp-Tests-Results.xml");
62 CPPUNIT_NS::XmlOutputter xml(&result, file);
65 }
catch (invalid_argument& e)
67 CPPUNIT_NS::stdCOut() << endl <<
"ERROR: " << e.what() << endl;
71 return result.wasSuccessful() ? 0 : 1;
int main(int argc, char *argv[])