我刚安装的Laravel出现问题。
当我尝试使用phpunit
命令运行默认ExampleTest.php
时,出现此错误:
D:\Laravel\Rahimi0151>phpunit
PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277
PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 285
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 285
PHPUnit 3.7.21 by Sebastian Bergmann.
Configuration read from D:\Laravel\Rahimi0151\phpunit.xml
Time: 0 seconds, Memory: 4.00Mb
[30;43m[2KNo tests executed!
[0m[2K
在底部说:
No tests executed!
有人可以帮助我解决问题吗?
答案 0 :(得分:4)
这里的问题是您正在运行的系统上安装的PHPUnit很旧,而不是应为此项目运行的PHPUnit。
要确保您运行的是为该项目安装的PHPUnit,您应该运行:
vendor/bin/phpunit
或
vendor/bin/phpunit.bat
答案 1 :(得分:0)
如果有人在这里搜索答案,则为:
php vendor/phpunit/phpunit/phpunit
并确保您的函数包含单词“ test”
例如
public function test_a_user_can_browse_threads()
{
...
}
编辑:这适用于laravel 7版
答案 2 :(得分:0)
正在运行7.0版Lumen,并被要求仅运行phpunit
无论如何运行phpunit
总是会产生No Test Executed
错误。
尝试了AdmirHusić的建议,运行php vendor/phpunit/phpunit/phpunit
,问题解决了,Lumen找到了测试文件并执行了该文件。
谢谢。