PHPUnit & Composer: [InvalidArgumentException] Command "path/to/test" is not defined

StackOverflow https://stackoverflow.com/questions/23239270

  •  08-07-2023
  •  | 
  •  

Вопрос

I have a directory with PHPUnit tests. Running

$ phpunit path/to/dir/*.php

Get an error:

[InvalidArgumentException]                                            
Command "path/to/dir/test_name.php" is not defined. 

Where test_name is the name of the first test in a directory.

I add Composer in the title, because if hide it in the test bootstrap, appear an error that missed Composer/Autoload/ClassLoader.php

What I have missed or what can be wrong?

Это было полезно?

Решение

Just pass the path, no filenames:

vendor/bin/phpunit path/to/dir

phpunit will automatically detect test files in that folder and it's subfolders. Note that I'm using the executable from vendor/bin because you said that you've installed using composer.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top