Filtering And Targeting Tests In PHP With PHPUnit And Pest
Targeting specific tests in PHP with Pest & PHPUnit: only(), filter, skip, todo() methods for efficient testing.
Nuno Maduro recently shared the ->only() method you can attach to tests with PestPHP. I love targeted ways to run and rerun tests efficiently, and this helper sparked an idea to collect the various ways to filter, skip, and target tests in PHP. This post is by no means exhaustive, but I hope to cover the most important techniques. I'll cover both PHPUnit and Pest, where each tool applies. Before we get started, here's a look at the only() method Nuno shared that you can attach to individual tests: it('returns a successful response', function () { $response = $this->get('/'); $response-...