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
![]() |
|