Question

I am trying to use Jenkins xUnit plug-in for my Qt unit test project, but I cannot make it work...

Here is What I've done so far:

First of all, I build my unit test project with qmakebuilder plug-in (providing the .pro to the qmakebuilder plug-in), then I add an Execute Shell build section where I first rm -f the testResult xml file, following to that, I run the test binary with -xunitxml flag to have it generate the xml file for me And I name the xml file testResult.xml, in other word:

rm -f /home/guest/QT/unitTest/testResult.xml
cd /home/guest/QT/unitTest
./tst_unittesttest -xunitxml > testResult.xml

Finally in Post Build Action, I select Publish xUnit test result and specify the pattern as *.xml.

Building the job will fail though, Here is the output that I get when building the job with Jenkins:

[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Processing QTestlib-Version N/A
[xUnit] [INFO] - [QTestlib-Version N/A] - 1 test report file(s) were found with
the pattern '*.xml' relative to '/home/guest/QT/unitTest' for the testing framework
'QTestlib-Version N/A'.
[xUnit] [ERROR] - The converted file for the result file '/home/guest/QT/unitTest
/testResult.xml' (during conversion process for the metric 'QTestlib') is not
valid.
The report file has been skipped.
[xUnit] [ERROR] - The plugin hasn't been performed correctly: hudson.util.IOException2:
Failed to read /home/guest/QT/unitTest/generatedJUnitFiles/QTestlib/TEST--735044756.xml
Build step 'Publish xUnit test result report' changed build result to FAILURE
Build step 'Publish xUnit test result report' marked build as failure
Finished: FAILURE

As you can see there is problem converting my test result xml file to what xUnit plug-in can read. My testResult.xml file looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="2" failures="0" tests="4" name="UnitTestTest">
  <properties>
    <property value="4.7.4" name="QTestVersion"/>
    <property value="4.7.4" name="QtVersion"/>
  </properties>
  <testcase result="pass" name="initTestCase">
    <!-- message="called before everything else" type="qdebug" -->
  </testcase>
  <testcase result="pass" name="myFirstTest"/>
  <testcase result="pass" name="mySecondTest"/>
  <testcase result="pass" name="cleanupTestCase">
    <!-- message="called after myFirstTest and mySecondTest" type="qdebug" -->
  </testcase>
  <system-err>
<![CDATA[called before everything else]]>
<![CDATA[called after myFirstTest and mySecondTest]]>
  </system-err>
</testsuite>

but TEST--735044756.xml is an one line xml file: <?xml version="1.0" encoding="UTF-8"?>

Anyone has a clue where am I doing what wrong? There should be a problem with generating the output xml file.

On a different note, I have added the log thingi in the system log Jenkins menu, it doesn't seem to be the reason for this problem though... at least IMO

Était-ce utile?

La solution

Executing the test binary with -xml flag will just work fine. Weirdly using -xunitxml creates corrupt xml file which its <testcase> doesn't have time attribute. Running the test binary only with -xml results in building the job successfully.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top