【问题标题】:Showing the result of QTestlib with Jenkins xUnit plug-in使用 Jenkins xUnit 插件显示 QTestlib 的结果
【发布时间】:2012-10-31 15:05:24
【问题描述】:

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

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

首先,我使用 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 文件:&lt;?xml version="1.0" encoding="UTF-8"?&gt;

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

另一方面,我在系统日志 Jenkins 菜单中添加了日志,但这似乎不是导致此问题的原因……至少 IMO

【问题讨论】:

    标签: qt jenkins jenkins-plugins qtestlib


    【解决方案1】:

    使用-xml 标志执行测试二进制文件就可以正常工作。奇怪地使用 -xunitxml 创建损坏的 xml 文件,其 &lt;testcase&gt; 没有 time 属性。仅使用 -xml 运行测试二进制文件会成功构建作业。

    【讨论】:

    • 我认为这取决于您在 xUnit 插件的配置中选择的格式。格式“QTestLib-Version N/A”(插件版本 1.50 中添加)需要 QTestLib 的 -xml 格式。
    猜你喜欢
    • 1970-01-01
    • 2019-02-11
    • 2016-05-03
    • 2017-09-25
    • 2018-10-19
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多