Boost.Test XML Reports for Continuous Integration
Following on from my Boost.Test primer, the key goal for me was test result reporting in a continuous integration server1. To support this, I needed to produce output from Boost.Test which I could easily consume in a plugin. As it happens, Boost.Test has built in support for producing XML reports, which are easy to parse and therefore integrate with other tools.
What was not obvious, though, was exactly how to produce output with the right level of detail. The most promising parameters in the documentation were report_format and report_level, and indeed these can be used to produce XML — but even the detailed version does not output the reason when a test case fails. It turns out that assertion failures are reported in log output, and the log format can be tweaked to produce XML (reformatted for readability):
$ ./main --log_format=XML
<TestLog>
<Error file="main.cpp" line="20">check add(2, 2) == 5 failed</Error>
<Error file="main.cpp" line="25">check add(2, 2) == 1 failed</Error>
</TestLog>
To get output for passing tests, and for test suites, I also had to adjust the log_level to test_suite
$ ./main --log_format=XML --log_level=test_suite
<TestLog>
<TestSuite name="PulseTest">
<TestSuite name="VariantsSuite">
<TestCase name="simplePass">
<TestingTime>0</TestingTime>
</TestCase>
<TestCase name="checkFailure">
<Error file="main.cpp" line="20">check add(2, 2) == 5 failed</Error>
<TestingTime>0</TestingTime>
</TestCase>
...
</TestSuite>
</TestSuite>
</TestLog>
Bingo! Now the XML output has all the details required to render the test results nicely in a continuous integration server, provided the server has a plugin to read the XML.
—
1 In my case obviously Pulse, but XML reports are likely to be the easiest way to integrate with other CI servers too.
This entry was posted on Tuesday, April 7th, 2009 at 8:26 am and is filed under Agile, C++, Continuous Integration, Technology, Testing. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
