xdebug:phpunit 的代码覆盖致命错误
xdebug : Fatal error with phpunit for code coverage
我想测试我的代码和覆盖率。我已经安装了 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 我有一个致命错误 :
Sebastian Bergmann 和贡献者的 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_enable = On
,所以我不明白为什么系统会这样说:/
也许有人可以帮助我?非常感谢您对我的帮助!
I already add xdebug.coverage_enable = On
in my php.ini file so I don't understand why the system say that :/
Xdebug v3.0.0RC1
PHPUnit 7.5.20
将 PHPUnit 升级到了解 Xdebug 3 的版本...或者将 Xdebug 降级到 2.x(2.9.8 是最新的)。
事情是:xdebug.coverage_enable
是 Xdebug 2 选项。 该选项在 Xdebug 3 中没有任何作用,您应该使用 xdebug.mode = coverage
代替。
Xdebug 3 使用与 v2 不同的配置选项,而您的 PHPUnit 版本根本不知道这一点。对于不再使用的 Xdebug 2 选项,Xdebug 3 将简单地报告一个空 value/0。
https://3.xdebug.org/docs/upgrade_guide#Changed-Configuration-Settings
P.S. 当你 运行 php -i
使用 Xdebug 时,你 应该 看到警告3 -- 如果你的 php.ini 中存在这样的 wrong/outdated 选项,它应该会抱怨(除非你已将 PHP 配置为不报告任何启动错误 我猜).
在任何一种情况下:运行 php -i
并查看 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) 2002-2020, by Derick Rethans
with Zend OPcache v7.4.12, Copyright (c), by Zend Technologies
但是如果我 运行 phpunit 我有一个致命错误 :
Sebastian Bergmann 和贡献者的 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_enable = On
,所以我不明白为什么系统会这样说:/
也许有人可以帮助我?非常感谢您对我的帮助!
I already add
xdebug.coverage_enable = On
in my php.ini file so I don't understand why the system say that :/
Xdebug v3.0.0RC1
PHPUnit 7.5.20
将 PHPUnit 升级到了解 Xdebug 3 的版本...或者将 Xdebug 降级到 2.x(2.9.8 是最新的)。
事情是:xdebug.coverage_enable
是 Xdebug 2 选项。 该选项在 Xdebug 3 中没有任何作用,您应该使用 xdebug.mode = coverage
代替。
Xdebug 3 使用与 v2 不同的配置选项,而您的 PHPUnit 版本根本不知道这一点。对于不再使用的 Xdebug 2 选项,Xdebug 3 将简单地报告一个空 value/0。
https://3.xdebug.org/docs/upgrade_guide#Changed-Configuration-Settings
P.S. 当你 运行 php -i
使用 Xdebug 时,你 应该 看到警告3 -- 如果你的 php.ini 中存在这样的 wrong/outdated 选项,它应该会抱怨(除非你已将 PHP 配置为不报告任何启动错误 我猜).
在任何一种情况下:运行 php -i
并查看 Xdebug 部分的实际实时值:该选项具有什么值。