我正在使用 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%...