Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6013699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:35:13+00:00 2026-05-23T02:35:13+00:00

I’m using CTest (part of CMake) for my automated tests. How do I get

  • 0

I’m using CTest (part of CMake) for my automated tests.

How do I get CTest results in the Jenkins dashboard ? Or, phrased differently, how do I get CTest to output in JUnit-like XML ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:35:14+00:00Added an answer on May 23, 2026 at 2:35 am

    In Jenkins, after the CMake part (probably made through the CMake plugin), add the following batch script, or adapt for builds on Linux :

    del build_32\JUnitTestResults.xml
    pushd build_32\Tests
    "C:\Program Files\CMake 2.8\bin\ctest.exe" -T Test -C RelWithDebInfo --output-on-failure
    popd
    verify >nul
    C:\Python27\python.exe external/tool/CTest2JUnit.py build_32/Tests external/tool/CTest2JUnit.xsl > build_32/JUnitTestResults.xml
    
    • build_32 is the Build Directory in the CMake plugin
    • Tests is the subdirectory where all my tests live
    • -T Test makes CTest output in XML (?!)
    • verify >nul resets errorlevel to 0, because CTest returns >0 if any test fails, which Jenkins interprets as “the whole build failed”, which we don’t want
    • The last line converts CTest’s XML into a minimal JUnit xml. The Python script and the xslt live in the source directory, you may want to change that.

    The python script looks like this (hacked together in 10 min, beware) :

    from lxml import etree
    import StringIO
    import sys
    
    TAGfile = open(sys.argv[1]+"/Testing/TAG", 'r')
    dirname = TAGfile.readline().strip()
    
    xmlfile = open(sys.argv[1]+"/Testing/"+dirname+"/Test.xml", 'r')
    xslfile = open(sys.argv[2], 'r')
    
    xmlcontent = xmlfile.read()
    xslcontent = xslfile.read()
    
    xmldoc = etree.parse(StringIO.StringIO(xmlcontent))
    xslt_root = etree.XML(xslcontent)
    transform = etree.XSLT(xslt_root)
    
    result_tree = transform(xmldoc)
    print(result_tree)
    
    • It needs lxml, direct link
    • It takes two arguments, the directory in which the tests live (in the build directory), and a xsl file
    • It simply reads the last xml tests results, transforms it with the xsl, and outputs it to stdout
    • The “last xml tests” are present in the first line of the Testing/TAG file, hence the additional fopen

    The xsl looks like this. It’s pretty minimal but gets the job done : [EDIT] see MOnsDaR ‘s improved version : http://pastebin.com/3mQ2ZQfa

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes"/>
    
        <xsl:template match="/Site/Testing">    
            <testsuite>
                <xsl:apply-templates select="Test"/>
            </testsuite>
        </xsl:template>
    
        <xsl:template match="Test">
            <xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
            <xsl:variable name="testcaseclassname"><xsl:value-of select= "FullName"/></xsl:variable>
            <testcase name="{$testcasename}" classname="{$testcaseclassname}">
                <xsl:if test="@Status = 'passed'">
                </xsl:if>
                <xsl:if test="@Status = 'failed'">
                    <error type="error"><xsl:value-of select="Results/Measurement/Value/text()" /></error>
                </xsl:if>
                <xsl:if test="@Status = 'notrun'">
                    <skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
                </xsl:if>
            </testcase>
        </xsl:template>
    
    </xsl:stylesheet>
    

    Finally, check “Publish JUnit tests results” (or similar, my version is in French) and set the xml path to build_32/JUnitTestResults.xml

    Well, that was ugly. But still, hope this helps someone. And improvements are welcome ( running ctest from python maybe ? Using the path of the Python plugin instead of C:… ? )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.