Pest vs PHPUnit in Laravel: practical differences after 6 months
Team switched from PHPUnit to Pest 6 months ago on a new Laravel 11 project. Documenting what changed and whether we would make the same choice.
Pest tests read significantly better for feature tests. The it() and describe() structure maps well to user stories. Unit tests are less different from PHPUnit style.
The dataset feature (data providers) is much cleaner in Pest than PHPUnit data providers. No static methods, no associative arrays, just ->with([]).
Higher order tests and expectations are great for asserting on collections. $this->assertCount() vs ->count() is a readability improvement. Also the failure messages are better formatted.
PHPUnit compatibility layer means Pest runs PHPUnit tests without changes. Migration is gradual: new tests in Pest, keep old PHPUnit tests as-is until you have time to convert them.
One downside: IDE support was weaker 6 months ago. PHPStorm now has better Pest support but some completion features still lag behind PHPUnit. Minor issue but worth knowing.
The arch() test feature in Pest is genuinely useful: assert that controllers do not depend on repositories directly, that models do not have HTTP-specific code, etc. Enforces architecture constraints in CI.
```php blocks are runnable.