Back to Course |
Testing in Laravel 9 For Beginners: PHPUnit, Pest, TDD

Php artisan test Flags: Run Specific Test(s)

We have covered a lot of tests related to our product CRUD. The final tip in this section is, what if you want to test some part from the whole test?


While running php artisan test, you can specify a filter where you can provide a class name or test name.

For example, running php artisan test --filter=AuthTest will run all tests that are in the tests/Feature/AuthTest.php file.

filter auth tests

By specifying a method name, it will run only that test.

filter specific test

So if you don't want to run every test, which might take some time for bigger projects, you can run specific tests that you are working on right now. Before deploying the project, I still advise running a full test sweet. Because quite often, as developers, other parts of our application are affected by our newly changed code.


Now you have the most important basics of how to write tests, the syntax. In the next chapter, we will discuss what to test, how to decide what tests to write, and what tests are worth our time.