You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
建议使用 phpdbg 来生成测试覆盖率报告 #3389
前提
阅读 SDebug README 有如下说明
为了避免 swoole 的检测 xdebug 警告, 扩展注册的名称是 sdebug, 如果想使用 Phpunit CodeCoverage , 需要手动把检测 xdebug 的判断修改成 sdebug。
因此需要对如下文件进行修改
修改完上述文件代码后修改 phpunint.xml
processUncoveredFiles="true"
否则会抛出异常<directory suffix=".php">./runtime/container/proxy</directory>
将代理类也加入测试覆盖范围运行测试
co-phpunit -c phpunit.xml --colors=always --coverage-html ./runtime/codeCoverage
执行成功后 会在
./runtime/codeCoverage
中生产对应测试报告测试报告生产出来了,但是覆盖率始终未
0
cs-fix
会添加@coversNothing
去除
test/Cases/ExampleTest.php
中的@coversNothing
再次执行
co-phpunit -c phpunit.xml --colors=always --coverage-html ./runtime/codeCoverage
就能正确的生产测试覆盖率报告了与 Hyperf 2.0 差异
hyperf 2.1 对 phpunit 的依赖从
^7.0.0
提升到^9.4
阅读 PHPunit 的 ChangeLog-8.5 可知 phpunit 支持了 xdebug 3因此hyperf 2.0 要支持测试覆盖率只需将 Xdebug3Driver、Xdebug2Driver 的修改调整为修改
Beta Was this translation helpful? Give feedback.
All reactions