Update: (2011.09.06) Fixed references to Hudson, which has since been renamed to Jenkins.

For one of the projects I’ve been working on lately, I’ve been making use of Glib’s Testing functionality to write unit tests for a C-based project. I’m a fairly big fan of the Jenkins Continuous Integration Server and I wanted to run tests for my C-based project.

Unfortunately, the gtester application generates XML in a custom format that Jenkins cannot understand (i.e. JUnit formatted XML). In order to come up with some JUnit XML, I spent about an hour and a half toying with XSLT for transforming the XML gtester generates (see the snippet below).

I added a shell script build step to the end of the build process that runs:

gtester test_app --keep-going -o=Tests.xml
xsltproc -o tests.junit.xml gtester.xsl Tests.xml

Then I just specified “tests.junit.xml” in the Publish JUnit test result report section of the Post-build Actions and then Jenkins would properly process and post the test results when the job was finished.