laravel PHPunit 未捕获错误:调用未定义的方法 PHPUnit_Util_Configuration::getTestdoxGroupConfiguration()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41868027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:12:20  来源:igfitidea点击:

PHPunit Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration()

laravelphpunitlaravel-5.4

提问by ishadif

i don't know if it's related to Laravel 5.4. when i run phpunitcommand after installing laravel 5.4 without making any changes i get Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration()but when i run php artisan duskit runs normally

我不知道它是否与 Laravel 5.4 有关。当我phpunit在安装 laravel 5.4 后运行命令而不进行任何更改时,我得到了Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration()但是当我运行时php artisan dusk它运行正常

c:\xampp\htdocs\ublocker>phpunit
PHP Fatal error:  Uncaught Error: Call to undefined method
PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:1046
Stack trace:
#0 C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(167): PHPUnit_TextUI_TestRunner->handleConfiguration(Array)
#1 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(176): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#2 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 1046

Fatal error: Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:1046
Stack trace:
 C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(167): PHPUnit_TextUI_TestRunner->handleConfiguration(Array)
C:\xampp\php\pear\PHPUnit\TextUI\Command.php(176): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
{main}
thrown in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 1046

c:\xampp\htdocs\ublocker>phpunit
PHP Fatal error:  Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:1046
Stack trace:
#0 C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(167): PHPUnit_TextUI_TestRunner->handleConfiguration(Array)
#1 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(176): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#2 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 1046

Fatal error: Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php:1046
Stack trace:
#0    C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php(167): PHPUnit_TextUI_TestRunner->handleConfiguration(Array)
#1 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(176): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#2 C:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 C:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in C:\xampp\htdocs\ublocker\vendor\phpunit\phpunit\src\TextUI\TestRunner.php on line 1046

c:\xampp\htdocs\ublocker>php artisan dusk
PHPUnit 5.7.7 by Sebastian Bergmann and contributors.

F.                                                                  2 / 2 (100%)

any ideas how to fix this?

任何想法如何解决这一问题?

回答by arku

Seems like your version installed globally does not meet minimal required version. Try to run

似乎您在全球安装的版本不符合最低要求版本。尝试运行

phpunit --version

I bet you will get some like 5.1. The php artisan duskcommand uses different version which is located in vendor/bin/phpunit. So, you are also able to use this version instead. Just type:

我打赌你会得到一些喜欢的5.1。该php artisan dusk命令使用位于vendor/bin/phpunit. 因此,您也可以改用此版本。只需输入:

vendor/bin/phpunit

instead of phpunit. You have to upgrade your global phpunit version if it works.

而不是phpunit. 如果它有效,你必须升级你的全局 phpunit 版本。

回答by mpalencia

Had the same problem at Laravel 5.4. This worked for me.

在 Laravel 5.4 有同样的问题。这对我有用。

Step 1: update your composer

第 1 步:更新您的作曲家

composer update

Step 2: run the phpunit

第二步:运行phpunit

vendor/bin/phpunit

You can run a specific test by specifying the file

您可以通过指定文件来运行特定的测试

vendor/bin/phpunit tests/Feature/ExampleTest.php

回答by Taranjeet Singh

In my case the following command worked in windows environment, with \in place of /:

在我的情况下,以下命令在 Windows 环境中工作,\代替/

vendor\bin\phpunit

回答by Ali Yousefi

I have same issue ans solved with this step :

我有同样的问题,这一步解决了:

Check diff version

检查差异版本

$ phpunit --version
PHPUnit 6.5.5 by Sebastian Bergmann and contributors.

$ ./vendor/bin/phpunit --version
PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

Update global phpunit:

更新全局 phpunit:

if versions not equal update phpunit with

如果版本不等于更新 phpunit

 composer global require phpunit/phpunit:^8

check again versions

再次检查版本

$ phpunit --version
PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

$ ./vendor/bin/phpunit --version
PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

回答by Hussam Adil

For any who is experiencing this, vendor/bin/phpunitdefinitely works but you might want to add this line to your .bashrc or .bash_profile or whatever convenient for you to make it works.

对于任何遇到此问题的人来说,vendor/bin/phpunit绝对有效,但您可能希望将此行添加到您的 .bashrc 或 .bash_profile 或任何方便您使其工作的内容。

PATH="./vendor/bin:$PATH"

*tested on Linux only

*仅在 Linux 上测试

回答by Mhmd

I had same error with homestead laravel 5.6 when I ran phpunit command from my user it is works fine but when I ran it by sudo I got that error. try to run this command from your user not sudo maybe its work for you too

当我从我的用户运行 phpunit 命令时,我在 homestead laravel 5.6 上遇到了同样的错误,它工作正常,但是当我通过 sudo 运行它时,我得到了那个错误。尝试从您的用户而不是 sudo 运行此命令,也许它也适合您

回答by JohanTux

One solution is to add vendor/bin to the start of your path. On Unix like OSes running bash you can add the following to the end of your .bashrc file:

一种解决方案是将 vendor/bin 添加到路径的开头。在运行 bash 的类 Unix 操作系统上,您可以将以下内容添加到 .bashrc 文件的末尾:

export PATH=vendor/bin:$PATH

In Windows 10, you can access your Pathenvironment variable by accessing System Properties, Advancedtab and clicking the Environment Variables...button.

在 Windows 10 中,您可以Path通过访问系统属性高级选项卡并单击环境变量...按钮来访问环境变量

Either way, inserting vendor/bin at the front of the path will cause your OS to look for phpunit in ./vendor/bin. If you're in the root of your laravel project, it'll find the executable included with Laravel. If not, it'll move on to using the global version.

无论哪种方式,在路径前面插入 vendor/bin 都会导致您的操作系统在 ./vendor/bin 中查找 phpunit。如果您在 Laravel 项目的根目录中,它会找到 Laravel 中包含的可执行文件。如果没有,它将继续使用全球版本。