首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Jenkins xUnit插件显示QTestlib的结果

使用Jenkins xUnit插件显示QTestlib的结果
EN

Stack Overflow用户
提问于 2012-11-12 15:01:59
回答 1查看 5.9K关注 0票数 10

我正在尝试为我的Qt单元测试项目使用Jenkins xUnit插件,但我无法使其工作……

以下是我到目前为止所做的工作:

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

代码语言:javascript
复制
rm -f /home/guest/QT/unitTest/testResult.xml
cd /home/guest/QT/unitTest
./tst_unittesttest -xunitxml > testResult.xml

最后,在Post Build Action中,我选择Publish xUnit test result并将模式指定为*.xml

构建作业将会失败,以下是我使用Jenkins构建作业时得到的输出:

代码语言:javascript
复制
[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文件如下所示:

代码语言:javascript
复制
<?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"?>

有人知道我哪里做错了吗?在生成输出xml文件时应该会出现问题。

另外,我在系统日志Jenkins菜单中添加了日志thingi,这似乎不是导致这个问题的原因……至少是IMO

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-12 16:34:22

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

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13339513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档