Run only one test in PHPUnit

Run only one test in PHPUnit

While writing your tests, you of course don't want to run your whole test suite again and again to check if one tests runs through. There are ways to group tests with @group annotations and ways to run just one file by suppling the path to the file.

But there is a simpler way with the use of the --filter option:

phpunit --filter name_of_the_method

Sometimes you might have the same method name in multiple files. If so, you can also supply the path to the file:

phpunit --filter name_of_the_method path/to/the/file.php