|
@@ -2,8 +2,13 @@
|
|
#include <cppunit/CompilerOutputter.h>
|
|
#include <cppunit/CompilerOutputter.h>
|
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
|
#include <cppunit/ui/text/TestRunner.h>
|
|
#include <cppunit/ui/text/TestRunner.h>
|
|
|
|
+#include <cppunit/TestResult.h>
|
|
|
|
+#include <cppunit/TestResultCollector.h>
|
|
|
|
+#include <cppunit/XmlOutputter.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* CppUnit-Testrunner
|
|
* CppUnit-Testrunner
|
|
*/
|
|
*/
|
|
@@ -12,22 +17,34 @@ int main(int argc, char* argv[]) {
|
|
(void)argc;
|
|
(void)argc;
|
|
(void)argv;
|
|
(void)argv;
|
|
#ifdef NICE_USELIB_CPPUNIT
|
|
#ifdef NICE_USELIB_CPPUNIT
|
|
|
|
+ CppUnit::TestResult controller;
|
|
|
|
+ CppUnit::TestResultCollector result;
|
|
|
|
+ controller.addListener(&result);
|
|
|
|
+
|
|
// Get the top level suite from the registry
|
|
// Get the top level suite from the registry
|
|
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
|
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
|
|
|
|
|
// Adds the test to the list of test to run
|
|
// Adds the test to the list of test to run
|
|
- CppUnit::TextUi::TestRunner runner;
|
|
|
|
|
|
+ CppUnit::TestRunner runner;
|
|
runner.addTest( suite );
|
|
runner.addTest( suite );
|
|
|
|
|
|
// Change the default outputter to a compiler error format outputter
|
|
// Change the default outputter to a compiler error format outputter
|
|
- runner.setOutputter(
|
|
|
|
- new CppUnit::CompilerOutputter(&runner.result(), std::cerr));
|
|
|
|
|
|
+ // Print test in a compiler compatible format.
|
|
|
|
+ CppUnit::CompilerOutputter outputter( &result, std::cerr );
|
|
|
|
+ outputter.write();
|
|
|
|
|
|
// Run the tests
|
|
// Run the tests
|
|
- bool wasSucessful = runner.run();
|
|
|
|
-
|
|
|
|
|
|
+ runner.run( controller );
|
|
|
|
+ std::string sTestName = suite->getName();
|
|
|
|
+ //std::string sTestName = runner.getName();
|
|
|
|
+ sTestName.append( "_testresults.xml");
|
|
|
|
+ std::cout << sTestName <<std::endl;
|
|
|
|
+ std::ofstream xmlFileOut(sTestName.c_str());
|
|
|
|
+ CppUnit::XmlOutputter xmlOut(&result, xmlFileOut);
|
|
|
|
+ xmlOut.write();
|
|
|
|
+
|
|
// Return error code 1 if one of tests failed.
|
|
// Return error code 1 if one of tests failed.
|
|
- return wasSucessful ? 0 : 1;
|
|
|
|
|
|
+ return result.wasSuccessful() ? 0 : 1;
|
|
#else
|
|
#else
|
|
#error "Install cppunit (http://cppunit.sourceforge.net/cppunit-wiki)"
|
|
#error "Install cppunit (http://cppunit.sourceforge.net/cppunit-wiki)"
|
|
return 1;
|
|
return 1;
|