【问题标题】:phing versus phpunit codecoverage resultsphing 与 phpunit 代码覆盖率结果
【发布时间】:2011-01-18 00:46:54
【问题描述】:

我为 phing 创建了一个 build.xml 文件来创建代码覆盖率报告。它使用

phpunit codecoverage="true"

并指向与 phpunit --coverage-html 相同的文件。然而,结果不同。使用 phing,我对所有文件都有 100% 的代码覆盖率,而我没有。关于使用 phing 运行代码覆盖率,我可能不知道一些事情可以解释这一点 100%。我做错了什么以获得不同的结果?

【问题讨论】:

    标签: php code-coverage phpunit phing


    【解决方案1】:

    您可以尝试将 phpunit 作为可执行文件运行,并将 --coverage-html 作为参数运行(我们就是这样做的,而且看起来效果很好)。

    例子:

    <target name="phpunit">
     <exec executable="phpunit" dir="${basedir}/source" failonerror="on">
      <arg line="--log-junit ${basedir}/build/logs/phpunit.xml
      --coverage-clover ${basedir}/build/logs/phpunit.coverage.xml
      --coverage-html ${basedir}/build/coverage
      tests/" />
     </exec>
    </target>
    

    【讨论】:

    • 有什么区别?您解决了什么问题?
    【解决方案2】:

    第一个答案中的示例不起作用。此示例为 Ant。 Phing ExecTask 不支持将“arg”作为嵌套元素。

    Phing 的工作示例:

    <target name="phpunit">
        <exec command="phpunit --log-junit ${logsdir}/phpunit.xml 
            --coverage-clover ${logsdir}/phpunit.coverage.xml 
            --coverage-html ${logsdir}/coverage 
            tests/" />
    </target>
    

    【讨论】:

      猜你喜欢
      • 2012-05-04
      • 2023-03-23
      • 2018-05-29
      • 2012-08-04
      • 2012-01-18
      • 2012-01-14
      • 2011-05-27
      • 2013-11-01
      • 1970-01-01
      相关资源
      最近更新 更多