当我在 PHPstorm 中运行我的测试套件时,所有代码覆盖率都返回 0%(我知道这不是真的),当我从命令行运行 PHPunit 时,记录的 HTML 输出文档显示我实际上一定要有报道并列出所有详细信息。
在 PHPstorm 中,我将 PHP 解释器设置为/usr/local/bin/php (PHP 5.6.7) 和 xdebug 2.3.2(屏幕截图:https://dl.dropboxusercontent.com/u/379071/Screen%20Shot%202015-04-20%20at%206.57.39%20PM.png)。在我的 PHPunit 首选项中,我将“脚本路径”设置为我的 composer autoload.php 文件。在我的运行时配置中,我将 PHPunit 运行时设置为使用“定义的配置文件”运行(见下文)。当我运行时,所有测试都运行并通过(失败显示堆栈跟踪),但所有内容的代码覆盖率完全为零。
如有任何帮助,我们将不胜感激。我确定我刚刚错过了一些东西。
我的 XML 配置文件的内容:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite>
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/codeCoverage" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="./log/testdox.html"/>
</logging>
</phpunit>
最佳答案
我知道这是一个旧话题,但我刚遇到这个问题。在我的例子中,项目路径包含一个指向不同硬盘的符号链接(symbolic link)。通过将项目根目录更改为绝对路径 (/media/hdd/...),我能够解决问题。
关于PHPstorm PHPunit 代码共同覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29759999/