Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Tag Archives: junit

Generate JUnit XML format for Jenkins from CMake CTest

In JUnit XML Skeleton fits for Hudson., I showed the minimal JUnit XML for showing  meaningful results in Hudson/Jenkins.

But how to generate the JUnit XML from cmake and ctest?

I got the inspiration from How to get CTest results in Hudson / Jenkins in StackOverflow and create following  CTest2JUnit.xsl.

To use the xsl, you may either use the I provide in the same directory, or following command in Linux:

xsltproc CTest2JUnit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > JUnitTestResults.xml

JUnit XML Skeleton fits for Hudson

Hudson built-in supports JUnit XML reports. But unfortunately, the thing I want Hudson to show is neither written in Java, nor generate by JUnit, yet I managed to create a minimal JUnit XML that is accepted by Hudson. Here is how it looks like:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="1" failures="1" hostname="HOSTNAME" name="PACKAGENAME" tests="3" time="3.0" timestamp="2010-06-30T05:16:00Z">
  <testcase name="TESTCASE1-SUCCESS" time="1.0" />
  <testcase name="TESTCASE2-ERROR" time="1.0">
    <error message="ERR_MSG">STACK_TRACE</error>
  <testcase name="TESTCASE3-FAILURE" time="1.0">
    <failure message="FAIL_MSG">STACK_TRACE</failure>

Replace all uppercase text strings with your strings, and attribute time,failure,error with real values.