This is how you normally use Unittest++'s built-in XML reporter:
std::ofstream f("test-report.xml");Simply replace it with the following,
UnitTest::XmlTestReporter reporter(f);
UnitTest::TestRunner runner(reporter);
return runner.RunTestsIf(UnitTest::Test::GetTestList(), NULL, UnitTest::True(), 0);
std::string f = "TESTS-";Note that the JUnit reporter does not take a complete filename because the JUnit format requires that different test suites are split into different files. The output files are named TESTS-suitename.xml.
UnitTest::JUnitXmlTestReporter reporter(f);
UnitTest::TestRunner runner(reporter);
return runner.RunTestsIf(UnitTest::Test::GetTestList(), NULL, UnitTest::True(), 0);
Download
JUnitXMLTestReporter.h
JUnitXMLTestReporter.cpp
Thanks!! I'm using this with Hudson, and I'm dumping all tests from different executables in one directory, passing the name of the executable to JUnitXmlTestReporter. So files are named 'testA_SuiteName.xml testB_SuiteName.xml' etc. Any way to get hudson to treat testA and testB as packages? Now it just shows package (root), and all tests under it. Would be nice if it would show package testA and package testB..
ReplyDeleteHello,
ReplyDeleteI found that the file links are broken. Is it possible to restore them?
thanks a lot!