CI集成phpunit Error: No code coverage driver is available 的解决

时间:2024-01-07 19:13:50

CI集成phpunit时,运行报No code coverage driver is available的错误,如下图:

yanglingdeMacBook-Pro:tests yangling$ phpunit
PHPUnit 6.1.3 by Sebastian Bergmann and contributors. Error: No code coverage driver is available .... 4 / 4 (100%) Time: 220 ms, Memory: 10.00MB

  请检查是否正确安装xdebug

yanglingdeMacBook-Pro:tests yangling$ php -i | grep xdebug

  如果你像上图一样提示,恭喜,你肯定没有出现以上错误。

  如果查找不到xdebug,可以使用brew进行安装xdebug,安装和你的php版本一致的xdebug

brew search xdebug
brew install homebrew/php/php70-xdebug
##宝宝的是php7.0.8

  CLi:

yanglingdeMacBook-Pro:tests yangling$ php -i | grep xdebug
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off

  

再运行phpunit

	PHPUnit 6.1.3 by Sebastian Bergmann and contributors.

	....                                                                4 / 4 (100%)

	Time: 577 ms, Memory: 14.00MB

	OK (4 tests, 4 assertions)

	Generating code coverage report in Clover XML format ... done

	Generating code coverage report in HTML format ... done

  好啦,成功啦!fighting