1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravel8 No tests executed!解決方法

Posted at

今回は、Laravel入門書の最後の項目である「ユニットテスト」で発生したエラーについてです!
( 参考書:Laravel入門(Laravel6), PC:Mac, Laravelバージョン:Laravel8 )

早速ですが、Laravel入門p.340,345,347のところで、PHPUnitを実行する為に、

$ vendor/bin/phpunit

参考書の通りこちらのコマンドをターミナルで実行したところ、下記のエラーが発生しました。

No tests executed!

No tests executed!

このエラーが出たら先ず、PHPUnitを実行するテストクラスの配置を確認します。

Laravelでのテストは、FeatureUnitディレクトリに分かれていて、
FeatureControllerのテストUnitそれ以外のテストという位置づけです。

デフォルトでは、tests/Featuretests/Unitディレクトリにテストクラスを配置する必要があります。

この時点で上記のディレクトリにテストクラスがないと今回のようなエラーが発生しますが、
僕の場合ディレクトリの配置は特に問題ありませんでした!

解決方法

今回の場合は、PHPUnit実行コマンドを下記のように変更したことで、正常にテストが実行され、テスト判定も問題なくOKが出ました!

$ vendor/bin/phpunit
↓ //変更
$ vendor/bin/phpunit tests/Unit/ExampleTest.php
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?