Laravel : phpunit 无法打开文件 ExampleTest.php
Laravel : phpunit cannot open file ExampleTest.php
嗨,我在 Laravel PHPUnit 中退出了新手,出现以下错误:
Laravel : phpunit cannot open file ExampleTest.php
我不知道为什么会出现此错误。我在全球范围内安装了 PHPUnit,当我在终端中 运行 "phpunit" 时,它 运行 没问题。但我想 运行 它在特定文件上,如 :
phpunit ExampleTest
提前致谢。
确保您位于项目根目录并引用测试文件夹中的文件。
示例:
phpunit tests/ExampleTest.php
我在Windows工作。尝试使用完整路径:
C:\Desktop\code\blog\vendor\bin>phpunit C:\Desktop\code\blog\tests\Feature\ExampleTest.php
PHPUnit 7.2.6 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 1.46 seconds, Memory: 10.00MB
OK (1 test, 1 assertion)
试试这样:
vendor\bin\phpunit tests\Unit\ExampleTest.php
它会乖乖地工作
但首先要全局安装 phpunit。
这在我升级 phpUnit 时开始发生,我不得不更新 phpStorm 来修复它。
也许你对你的测试调用错了。
像这样尝试:
php artisan test --filter YourTestClassName
嗨,我在 Laravel PHPUnit 中退出了新手,出现以下错误:
Laravel : phpunit cannot open file ExampleTest.php
我不知道为什么会出现此错误。我在全球范围内安装了 PHPUnit,当我在终端中 运行 "phpunit" 时,它 运行 没问题。但我想 运行 它在特定文件上,如 :
phpunit ExampleTest
提前致谢。
确保您位于项目根目录并引用测试文件夹中的文件。
示例:
phpunit tests/ExampleTest.php
我在Windows工作。尝试使用完整路径:
C:\Desktop\code\blog\vendor\bin>phpunit C:\Desktop\code\blog\tests\Feature\ExampleTest.php
PHPUnit 7.2.6 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 1.46 seconds, Memory: 10.00MB
OK (1 test, 1 assertion)
试试这样:
vendor\bin\phpunit tests\Unit\ExampleTest.php
它会乖乖地工作 但首先要全局安装 phpunit。
这在我升级 phpUnit 时开始发生,我不得不更新 phpStorm 来修复它。
也许你对你的测试调用错了。 像这样尝试:
php artisan test --filter YourTestClassName