Q: How can I print test result with Xunit in jenkins for QT5 multiple unit tests I have started developing QT project. I want to run multiple unit test in jenkins and I want to see test results in jenkins dashboard. So I installed Xunit plugin. And 1 unit test class is working. But I want to run multiple unit test or test suite. However I don't know how can I do with QT application. I tried a way. But it produced wrong xml format. Then Xunit gives error. I think reason of error is that there are two  

TestMathTokenizer testTokenizer;
TestMathParser testParser;
return QTest::qExec(&testTokenizer, argc, argv) |
        QTest::qExec(&testParser, argc, argv);

In jenkins I wrote command for post build:
qttest-example-test -xml > "C:\Program Files (x86)\Jenkins\workspace\hostGit\testResult2.xml"

Produced XML is following:
<?xml version="1.0" encoding="UTF-8"?>
<TestCase name="TestMathTokenizer">
<Environment>
    <QtVersion>5.2.1</QtVersion>
    <QTestVersion>5.2.1</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::initTestCase() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testEmpty">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[Inside TestMathTokenizer::testEmpty() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testInt">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testIntFail">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testExpr">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testUnexpectedCharacterFail">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testFutureFunctionality">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Incident type="xfail" file="test\testmathtokenizer.cpp" line="86">
    <Description><![CDATA[sqrt not implemented yet]]></Description>
</Incident>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testZero">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Incident type="fail" file="test\testmathtokenizer.cpp" line="95">
    <Description><![CDATA['false' returned FALSE. ()]]></Description>
</Incident>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
</TestFunction>
<TestFunction name="evilFunction">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::init() ]]></Description>
</Message>
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanup() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="cleanupTestCase">
<Message type="qdebug" file="" line="0">
    <Description><![CDATA[TestMathTokenizer::cleanupTestCase() ]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
</TestCase>
<?xml version="1.0" encoding="UTF-8"?>
<TestCase name="TestMathParser">
<Environment>
    <QtVersion>5.2.1</QtVersion>
    <QTestVersion>5.2.1</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testEmptyFail">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testInt">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testInvalidOperator">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testAllOperators">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testDivisionByZeroFail">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testUnexpectedEndFail">
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" />
</TestFunction>
</TestCase>

Error:
 Caused by: org.xml.sax.SAXParseException; lineNumber: 100; columnNumber: 6; The processing instruction target matching "[xX][mM][lL]" is not allowed.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at com.thalesgroup.dtkit.util.converter.ConversionService.convert(ConversionService.java:316)
    ... 21 more


A: The problem is that you have 2 xml tags (files) in one, as your code is generating one for each test-class that you have.
Your output should be parsed and splitted in 2 xmls, had the same issue.
Here is a CMD script that would split your file in 2:
set /a filenameCounter=0 
setlocal ENABLEDELAYEDEXPANSION 
for /f "tokens=*" %%a in (testResult2.xml) do (    
   if "%%a"=="<?xml version="1.0" encoding="ISO-8859-1"?>" (
       set /a filenameCounter=filenameCounter+1
   )
   set splitFile=file!filenameCounter!.xml
   echo %%a>>!splitFile! 
) 
endlocal 
del testResult2.xml

Add this script in Execute Windows batch command, of course if the build is under Windows, if not, I can provide a perl script for you.
