Pest is the testing framework most new Laravel projects reach for — it's built on PHPUnit underneath, so anything you learn here transfers, but the syntax is function-based and noticeably less ceremonial.
A feature test exercises your application the way a real request would: hitting a route, checking the response.
// tests/Feature/ProjectsTest.php
test('the projects page lists published projects', function () {
$project = Project::factory()->create(['status' => 'published']);
$response = $this->get('/projects');
$response->assertOk();
$response->assertSee($project->title);
});
Run it with:
php artisan test
assertOk() checks for a 200 status code, and assertSee() checks that specific text appears in the rendered HTML — between the two, you've verified both that the route works and that it's actually showing real data, not just returning an empty page.
Every test in Laravel runs against a separate testing database by default, and (with the RefreshDatabase trait) each test starts from a clean, migrated database — so tests never leak state into each other or depend on the order they run in:
uses(RefreshDatabase::class);
The habit worth building early: write the test for the behavior you're about to add before you add it, or at minimum immediately after. A test suite that only gets written once, long after the features already work, tends to test what the code already does rather than what it's actually supposed to do — which misses the bugs that matter.