gpt4 book ai didi

phpunit - xdebug : Fatal error with phpunit for code coverage

转载 作者:行者123 更新时间:2023-12-04 08:33:26 25 4
gpt4 key购买 nike

我想测试我的代码和覆盖率。我已经安装了 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,我会遇到一个 fatal error :

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 将简单地报告一个空值/0。

https://3.xdebug.org/docs/upgrade_guide#Changed-Configuration-Settings

P.S. 当您使用 Xdebug 3 运行 php -i 时,您应该看到警告——如果这样的错误/过时,它应该会提示选项存在于您的 php.ini 中(除非您已将 PHP 配置为不报告任何启动错误我猜)。

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

关于phpunit - xdebug : Fatal error with phpunit for code coverage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64918218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com