美文网首页
phpunit 的coverage 和 result 无法生成的

phpunit 的coverage 和 result 无法生成的

作者: 芒鞋儿 | 来源:发表于2021-02-27 00:22 被阅读0次

使用phpunit 的参数或者unittest设定file (phpunit.xml) 生成coverage 和 result, 但需要安装xdebug

如果出现以下message, 说明没有安装。

Warning:       No code coverage driver available

在mac/linux 下安装xdebug

pecl install xdebug

继续run phpunit,出现以下msg:

Warning:       XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

需要在php.ini 下加入:

xdebug.mode=coverage

无需重启,再次run phpunit,以下msg:

Warning:       No filter is configured, code coverage will not be processed

phpunit.xml 可能不对,可以通过以下command 正确设置

phpunit --generate-configuration

出现对话,按对话回答必须的配置
系统会自动生成phpunit.xml
此时运行以下的命令会生成相应的coverage和result

phpunit --coverage-clover clover.xml

test result则按照phpunit.xml 中定义生成。

附:
xdebug安装后php的performance会受到一些影响,参考:
https://medium.com/@nicocabot/speed-up-phpunit-code-coverage-analysis-4e35345b3dad

相关文章

网友评论

      本文标题:phpunit 的coverage 和 result 无法生成的

      本文链接:https://www.haomeiwen.com/subject/zdkbfltx.html