Executing only some PHPUnit tests

When you are creating new tests with PHPUnit, if you execute all tests, it can take some time to execute. To execute them faster, you can filter the tests you want to execute.

Executing one test

To execute only one test, you can use the --filter parameter and the test method you want to test:

./vendor/bin/phpunit --filter test_my_test

Executing all tests in a file

To execute all tests in a file, you can use the same --filter parameter and the class you want to test:

./vendor/bin/phpunit --filter My_test_class

More information available in the official documentation.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.