xdebug:phpunit用于代码覆盖率的致命错误

xdebug:phpunit用于代码覆盖率的致命错误,phpunit,xdebug,Phpunit,Xdebug,我想测试我的代码和覆盖率。我已经安装了Xdebug扩展,当我使用php-v命令进行验证时,所有这些都很好: PHP 7.4.12 (cli) (built: Oct 27 2020 17:18:47) ( ZTS Visual C++ 2017 x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Xdebug v3.0.0RC1, Copyright (c)

我想测试我的代码和覆盖率。我已经安装了Xdebug扩展,当我使用
php-v
命令进行验证时,所有这些都很好:

PHP 7.4.12 (cli) (built: Oct 27 2020 17:18:47) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v3.0.0RC1, Copyright (c) 2002-2020, by Derick Rethans
    with Zend OPcache v7.4.12, Copyright (c), by Zend Technologies 
但是,如果运行phpunit,则会出现致命错误:

PHPUnit 7.5.20由塞巴斯蒂安·伯格曼和贡献者撰写

Fatal error: Uncaught SebastianBergmann\CodeCoverage\RuntimeException: xdebug.coverage_enable=On has to be set in php.ini in C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\.phpunit\phpunit-7.5-0\vendor\phpunit\php-code-coverage\src\Driver\Xdebug.php on line 42

SebastianBergmann\CodeCoverage\RuntimeException: xdebug.coverage_enable=On has to be set in php.ini in C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\.phpunit\phpunit-7.5-0\vendor\phpunit\php-code-coverage\src\Driver\Xdebug.php on line 42

Call Stack:
    0.0005     402112   1. {main}() C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\phpunit:0
    0.0027     477240   2. require('C:\Users\quent\Desktop\Github\quentingeeraert-website\vendor\symfony\phpunit-bridge\bin\simple-phpunit.php') C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\phpunit:13
    0.2824     501760   3. include('C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\.phpunit\phpunit-7.5-0\phpunit') C:\Users\quent\Desktop\Github\quentingeeraert-website\vendor\symfony\phpunit-bridge\bin\simple-phpunit.php:405
    0.2989    1149952   4. PHPUnit\TextUI\Command::main($exit = ???) C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\.phpunit\phpunit-7.5-0\phpunit:22
    0.2989    1150064   5. Symfony\Bridge\PhpUnit\Legacy\CommandForV6->run($argv = [0 => 'bin\\phpunit', 1 => '--colors=always', 2 => '--stop-on-failure'], $exit = TRUE) C:\Users\quent\Desktop\Github\quentingeeraert-website\bin\.phpunit\phpunit-7.5-0\src\TextUI\Command.php:162
我已经在php.ini文件中添加了
xdebug.coverage\u enable=On
,所以我不明白为什么系统会这样说:/

也许有人能帮我?非常感谢你对我的帮助

我已经在php.ini文件中添加了
xdebug.coverage\u enable=On
,所以我不明白为什么系统会这样说:/

Xdebug v3.0.0RC1
PHPUnit 7.5.20

要么将PHPUnit升级到了解Xdebug 3的版本。。。或者将Xdebug降级到2.x(2.9.8是最新版本)


问题是:
xdebug.coverage\u enable
是xdebug 2的选项该选项在Xdebug 3中不起任何作用,您应该使用
Xdebug.mode=coverage

Xdebug 3使用与v2不同的配置选项,而您的PHPUnit版本根本不知道这一点。对于不再使用的Xdebug 2选项,Xdebug 3只会报告一个空值/0

p.S.当您使用Xdebug 3运行
php-i
时,应该会看到一条警告——如果php.ini中存在这样一个错误/过时的选项,它应该会抱怨(除非您已将php配置为不报告任何启动错误)


在任何一种情况下:运行
php-i
并查看Xdebug部分中的实际活动值:该选项具有什么值。

非常感谢,事实上,使用php-i时,该值设置为0。根据您的建议,我将xdebug降级为2.9.8,现在可以使用了。