I am using CPPUnit::XmlOutputter to write the unit test results to an XML file.
The program works as expected and I can see the test results in the xml file.
But I also want to add intermediate results and user defined messages in the same xml result file.
How do I do that in my Test function?
// my code is
main()
{
CppUnit::TextTestRunner runner;
std::ofstream outputFile("testResults.xml");
CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter( &runner.result(),
outputFile );
runner.setOutputter(outputter);
// MyTestClass is derived from CppUnit::TestFixture and uses CPPUNIT_TEST_SUITE macros.
MyTestClass::Test()
{
// I need to write the progress status to the output xml file while the test is runnin
}
/////
Thanks a ton,
Arti gujare
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can look into XmlOutputterHook (Hook to customize Xml output). I've used it to add custom info into the xml output. This class has methods to add info in the beginning or end of report, for each failed / successful test, or in statistics.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear All,
I am using CPPUnit::XmlOutputter to write the unit test results to an XML file.
The program works as expected and I can see the test results in the xml file.
But I also want to add intermediate results and user defined messages in the same xml result file.
How do I do that in my Test function?
// my code is
main()
{
CppUnit::TextTestRunner runner;
std::ofstream outputFile("testResults.xml");
CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter( &runner.result(),
outputFile );
runner.setOutputter(outputter);
runner.addTest(MyTestClass::suite());
runner.run();
}
// MyTestClass is derived from CppUnit::TestFixture and uses CPPUNIT_TEST_SUITE macros.
MyTestClass::Test()
{
// I need to write the progress status to the output xml file while the test is runnin
}
/////
Thanks a ton,
Arti gujare
Use the approach similar to the one suggested by the cppunit maintainer for associating test descriptions with testcases:
http://permalink.gmane.org/gmane.comp.lib.cppunit.devel/176
You can look into XmlOutputterHook (Hook to customize Xml output). I've used it to add custom info into the xml output. This class has methods to add info in the beginning or end of report, for each failed / successful test, or in statistics.