Back to Course |
Testing in Laravel 11 For Beginners

Quick Tip: Run Only SPECIFIC Tests

We have covered a lot of tests related to our product CRUD. The final tip in this section is about running the tests: what if you want to run a specific test file/method and not wait for all the tests to run?


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

You can also run, for example, only the Unit or Feature tests and stop when test fails.

Pest has more filtering parameters, which can be passed to the artisan command.

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.

But, before deploying the project, I still advise running a full test suite. 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.