Thursday, January 29th, 2009 | Author: frocksii

Hudson is a great continous build system. Currently we are using Hudson at B-Virtual to get real-time feedback on the quality of our code repositry on different platforms.

For testing our C++ code we are currently moving from Cunit to Google C++ Testing Framework. Googletest also has the possibility to generate a jUnit style report. jUnit style reports can be used by Hudson to visualize the succeeded and failed tests.

But the reports coming from Googletest can’t be imported by Hudson by default. The problem is that reports from Googletest have one level too much in the xml. The structure is the following:

<testsuite>
<testsuite>
<testcase></testcase>

<testcase></testcase>
</testsuite>

<testsuite>
<testcase></testcase>

<testcase></testcase>
</testsuite>
</testsuite>

To get the information in Hudson, the only thing that needs to be done is extracting the children of the main <testsuite> to different files per testsuite just containing this the following.

<testsuite>
<testcase></testcase>

<testcase></testcase>
</testsuite>

Importing these files works flawlesly. I did the split with a very simple python script:

from __future__ import with_statement
import xml.dom.minidom

gtests = xml.dom.minidom.parse(”gtest.xml”)
counter=0
for testsuites in gtests.childNodes:
for testsuite in testsuites.childNodes:
if testsuite.nodeName == “testsuite”:
counter +=1
f = open(”xmlreport/gtest%s.xml” % counter,”w”)
with f:
f.write(testsuite.toxml())

Category: Technology
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.
Leave a Reply » Log in


You must be logged in to post a comment.