【问题标题】:Coverage PHPUnit 0% with Jetbrains PHPStorm使用 Jetbrains PHPStorm 覆盖 PHPUnit 0%
【发布时间】:2016-01-13 18:47:34
【问题描述】:

我正在使用 Codeigniter3 框架和一个 phpunit 包ci-phpunit-test。 我在启用了 zend 调试器的 zend 服务器上运行 php。

我的 phpunit.xml 文件在那里:

<phpunit
    bootstrap="./Bootstrap.php"
    colors="true"
    testsuite="CodeIgniter Application Test Suite">
    <testsuites>
        <testsuite name="CodeIgniter Application Test Suite">
            <directory suffix="test.php">./</directory>
            <exclude>./_ci_phpunit_test/</exclude>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">../controllers</directory>
            <directory suffix=".php">../models</directory>
        </whitelist>
    </filter>
</phpunit>

我使用带有绿色播放和破折号的图标运行代码覆盖执行,这将运行以下命令:

"C:\Program Files (x86)\Zend\ZendServer\bin\php.exe" -dzend_debugger.enable_coverage=1 C:/Users/NICOLAS/AppData/Local/Temp/ide-phpunit.php --configuration C:\....\phpunit.xml

在成功运行所有测试后,Coverage PHPUnit 侧边栏打开并且只显示 0% 的覆盖率(我确定测试通过了很多代码)。

这是我得到的:

更新:更多信息... 当我在 phpunit.xml 文件中添加它时,它告诉我 Xdebug 未启用:

<logging>
    <log type="coverage-html" target="build/coverage"/>
    <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>

因此,我尝试启用 xdebug 调试器,但测试运行速度非常缓慢,并且我在 build/coverage 文件夹中获得了 HTML 报告。不错,但没有集成到 PHPStorm 环境中。

所以我回到了zend 调试器并尝试了PHPStorm 功能(删除了phpunit.xml 中的日志部分)。测试运行很快,但覆盖率保持在 0%...

【问题讨论】:

  • @craig_h 是的,我确定,我得到了所有通过测试的测试报告(我也可以调试它们)
  • @craig_h 我选中了“显示选项”和“激活覆盖视图”
  • @craig_h 添加/**@test**/ 不会改变任何东西

标签: php zend-framework phpunit code-coverage zend-debugger


【解决方案1】:

我遇到了同样的问题,这个 answer 成功了。

通过将项目根目录更改为绝对路径 (/media/hdd/...),我能够解决问题。

【讨论】:

  • 我遇到了同样的问题,它对我有用。我已经按照包含符号链接的路径打开了项目,因此我的项目根目录中有一个符号链接。当我使用已解析的符号链接打开项目时,代码覆盖率起作用了。
猜你喜欢
  • 2018-07-17
  • 2015-06-27
  • 2014-04-16
  • 2012-08-04
  • 2019-03-30
  • 2018-03-02
  • 1970-01-01
  • 2014-06-07
  • 2023-01-17
相关资源
最近更新 更多