phpunit実行時の No tests executed! 

No tests executedエラーに関して

phpunit実行するにあたり、phpunit.xmlを作成し、ターミナル上で

phpunit

だけ打って、テストを実行した。

すると上記のようなエラーが出た。

これを調べてみると、

  • php Laravelとphpunitのバージョンの違い

Laravel v5.4は、phpunit v5.7以下を使わなければならない。

  • phpunitの参照場所、パスの間違い

composer/vender/bin/phpunitを参照したほうがいい。

Laravelの中のphpunitではダメだということだろうか。

今回は、 phpunit tests/test.php  とすれば、テストは実行できたが、

phpunit だけではダメだった。Laravelを使っているわけでもなく、難しいことはわからないため、

たまたま見つけた下記の回答で解決した。

Your XML file is fine as it is. However, you have to make sure that the PHP files in your tests/ folder are named as follows:

tests/Test.php <— Note the uppercase “T”
tests/userTest.php
tests/fooBarTest.php
etc.

The filenames must end with “Test.php”. This is what PHPUnit is looking for within directories.

そう、ファイル名を大文字にした。

それで解決できた。

色々試したが、確かに小文字ではうまくテストは実行できなかった。

参考 : https://stackoverflow.com/questions/29299206/phpunit-no-tests-executed-when-using-configuration-file

【楽天1位】ノートパソコンスタンド パソコンスタンド 折りたたみ式 ノート PCスタンド 改良版 アルミ合金製 ホルダー 高さ 角度調整可能 滑り止め 軽量 姿勢改善 Macbook/Macbook Air/Macbook Pro/iPad//タブレットなど9~17インチまでに対応