作者:化合价steuart_968 | 来源:互联网 | 2022-10-12 12:54
我尝试使用PHPUnit v8。但是,我没有用PhpStorm成功。当我在PhpStorm中运行简单测试(类方法)时,收到以下消息:
PHP Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'Mrself\\TreeType\\Tests\\Functional\\BuildingTest' could not be found in '/vagrant/symfony-tree-type/tests/Functional/BuildingTest.php'. in /vagrant/symfony-tree-type/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php:65
是的,我有该类,是的,我已正确配置了psr:
"autoload": {
"psr-4": {
"Mrself\\TreeType\\": "./src/"
}
},
"autoload-dev": {
"psr-4": {
"Mrself\\TreeType\\Tests\\": "./tests/"
}
}
我一切设置正确的证明是,当我运行vendor/bin/phpunit
它时,它给我正确的结果。
当我在PhpStorm中运行方法时,得到了以下调用:
/usr/bin/php /vagrant/symfony-tree-type/vendor/phpunit/phpunit/phpunit --configuration /vagrant/symfony-tree-type/phpunit.xml --filter "/(::testFormCanBeBuild)( .*)?$/" Mrself\\TreeType\\Tests\\Functional\\BuildingTest /vagrant/symfony-tree-type/tests/Functional/BuildingTest.php --teamcity
但是,如果我将类名称空间放在前面,那么\\
一切也将正常运行。我不知道发生了什么事。PHPUnit版本7也可以正常工作。