使用Jenkins xUnit插件显示QTestlib的结果 [英] Showing the result of QTestlib with Jenkins xUnit plug-in

查看:254
本文介绍了使用Jenkins xUnit插件显示QTestlib的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Jenkins xUnit插件用于Qt单元测试项目,但是我无法使其工作...

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:

首先,我使用qmakebuilder插件构建我的单元测试项目(向qmakebuilder插件提供.pro),然后添加一个Execute Shell构建部分 我首先在其中找到rm -f testResult xml文件,然后,我使用-xunitxml标志运行测试二进制文件,以使其为我生成xml文件,然后将xml文件命名为testResult.xml,换句话说:

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

最后,在构建后操作"中,选择"Publish xUnit test result"并将模式指定为"*.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

您可以看到将我的测试结果xml文件转换为xUnit插件可以读取的问题.我的testResult.xml文件如下所示:

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>

但是TEST--735044756.xml是单行xml文件:<?xml version="1.0" encoding="UTF-8"?>

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

任何人都知道我在哪里做错了什么?生成输出xml文件应该有问题.

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

换句话说,我在系统日志Jenkins菜单中添加了"thingi"日志,尽管这似乎不是造成此问题的原因,但至少是IMO

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

推荐答案

使用-xml标志执行测试二进制文件将可以正常工作.奇怪地使用-xunitxml会创建损坏的xml文件,该文件的<testcase>没有time属性.仅使用-xml运行测试二进制文件会成功构建作业.

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.

这篇关于使用Jenkins xUnit插件显示QTestlib的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆