【问题标题】:Hudson CI and PHPUnit: None of the test reports contained any resultHudson CI 和 PHPUnit:没有任何测试报告包含任何结果
【发布时间】:2011-01-09 16:34:19
【问题描述】:

我正在尝试使用 xUnit 插件将我的 PHPUnit 测试集成到 Hudson 中。在 hudson 中使用 Ant 成功构建后,控制台输出显示:

记录测试结果
没有任何测试报告包含任何结果

我使用 phpunit --log-junit 的 junit.xml 测试输出如下:

<testsuites>
  <testsuite name="Unit Tests" tests="1" assertions="1" failures="0" errors="0" time="0.005112">
  <testsuite name="DbTest" file="src/tests/unit/DbTest.php" tests="1" assertions="1" failures="0" errors="0" time="0.005112">
    <testcase name="testConnection" class="DbTest" file="src/tests/unit/DbTest.php" line="4" assertions="1" time="0.005112"/>
    </testsuite>
  </testsuite>
</testsuites>

感谢任何帮助

编辑: 我刚刚创建了一个测试 junit.xml,其中包含:

<testsuites>
  <testsuite name="DbTest" file="src/tests/unit/DbTest.php" tests="1" assertions="1" failures="0" errors="0" time="0.005112">
    <testcase name="testConnection" class="DbTest" file="src/tests/unit/DbTest.php" line="4" assertions="1" time="0.005112"/>
    </testsuite>
</testsuites>

有了这个,构建就成功了。问题似乎是嵌套的标签。知道如何防止 PHPUnit 创建这些嵌套标签吗?

【问题讨论】:

    标签: xml junit hudson phpunit


    【解决方案1】:

    我终于在How might I integrate phpunit with Hudson CI? 找到了使用 xslt 解决方法的解决方案。

    如果有人遇到同样的问题:在项目根目录下的任意位置创建一个新的 .xsl 文件:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:element name="testsuites">
            <xsl:for-each select="//testsuite[@file]">
                     <xsl:copy-of select="." />
            </xsl:for-each>
        </xsl:element>
    </xsl:template>
    </xsl:stylesheet>
    

    然后添加到您的 build.xml 中(不要忘记包含在构建目标中):

    <target name="phpunit_to_xunit">
      <xslt in="build/logs/phpunit.xml" out="build/logs/junit.xml" style="phpunit_to_xunit.xsl"/>
    </target>
    

    无论如何,这有点麻烦。因此,我已经为 xUnit 项目提出了改进建议。

    【讨论】:

    • 感谢分享您的解决方案! +1
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-31
    • 1970-01-01
    相关资源
    最近更新 更多