qt - 使用Jenkins xUnit插件显示QTeSTLib的结果

标签 qt jenkins jenkins-plugins qtestlib

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

这是我到目前为止所做的:

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

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构建作业时获得的输出:
[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文件如下所示:
<?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

最佳答案

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

关于qt - 使用Jenkins xUnit插件显示QTeSTLib的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13339513/

相关文章:

c++ - QT中如何将QComboBox值转换为int

c++ - 使委托(delegate) QtComboBox 能够检测点击

java - Jenkins 显示 log4j 提示 : log4j:WARN No appenders could be found for logger

.net - Jenkins、MSBuild 和 Web 部署 : Unable to create Web Package

Jenkins-进程卡在插件安装的入门页面上

c++ - 如何在数据更改时强制模型更新 QComboBox?

android - Jenkins 尝试启动工具/模拟器而不是模拟器/模拟器(Android 模拟器插件)

jenkins - 使用 CopyArtifact 从特定版本复制

jenkins - 更改管道阶段之间的节点

c++ - ShellExecuteEx & GetExitCodeProcess - 处理无效或段错误