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