21 #ifndef __XAOMAINTEST_HXX__
22 #define __XAOMAINTEST_HXX__
24 #include <cppunit/CompilerOutputter.h>
25 #include <cppunit/TestResult.h>
26 #include <cppunit/TestResultCollector.h>
27 #include <cppunit/TextTestProgressListener.h>
28 #include <cppunit/BriefTestProgressListener.h>
29 #include <cppunit/extensions/TestFactoryRegistry.h>
30 #include <cppunit/TestRunner.h>
57 if (strcmp(argv[i],
"-l") == 0 || strcmp(argv[i],
"--list") == 0)
61 else if (strcmp(argv[i],
"-e") == 0 || strcmp(argv[i],
"--err") == 0)
65 else if (strcmp(argv[i],
"-t") == 0 || strcmp(argv[i],
"--test") == 0)
79 std::cout << test->getName() << std::endl;
80 for (
int i = 0; i < test->getChildTestCount(); ++i)
92 int main(
int argc,
char* argv[])
97 CPPUNIT_NS::TestResult controller;
100 CPPUNIT_NS::TestResultCollector result;
101 controller.addListener(&result);
105 CPPUNIT_NS::TextTestProgressListener progress;
107 CPPUNIT_NS::BriefTestProgressListener progress;
109 controller.addListener(&progress);
113 CPPUNIT_NS::Test *suite =
114 CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
125 if (!args.
Test.empty())
129 suite = suite->findTest(args.
Test);
132 CPPUNIT_NS::TestRunner runner;
133 runner.addTest(suite);
134 runner.run(controller);
140 CPPUNIT_NS::CompilerOutputter outputter(&result, std::cerr);
145 std::ofstream testFile;
146 testFile.open(
"UnitTestsResult", std::ios::out | std::ios::trunc);
147 CPPUNIT_NS::CompilerOutputter outputter(&result, testFile);
154 bool wasSucessful = result.wasSuccessful();
158 return wasSucessful ? 0 : 1;