Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top