Skip to main content

Testing for Laravels

Laravel testing is the practice of verifying application behaviour with PHPUnit or Pest. Feature tests make HTTP requests against routes and assert responses and database state, unit tests check isolated classes, and framework helpers such as factories, fakes and RefreshDatabase keep tests fast and repeatable.

Stage: Quality and Deployment · Part of the Laravel roadmap · Last reviewed 19 November 2026

What to learn in Testing

Testing interview questions

What is the difference between a feature test and a unit test in Laravel?

A feature test boots the application and exercises a larger path, such as an HTTP request through routing, middleware and the database. A unit test checks one class or method in isolation without the framework. Laravel apps tend to rely heavily on feature tests.

How do you test code that sends email without sending it?

Call Mail::fake() at the start of the test, run the action, then assert with Mail::assertSent for the expected mailable. The fake records messages instead of delivering them, so the test is quick and does not depend on a mail server.

Where Testing fits in the Laravel roadmap

Testing belongs to the Quality and Deployment stage (advanced level). Ship.

Back to the full Laravel roadmap