A Roundup of Laravel Testing Resources and Packages

Published on by

A Roundup of Laravel Testing Resources and Packages image

Testing code is one of the more challenging parts of programming, but luckily Laravel and some other tools are making it easier than ever. Research has even shown implementing a Test-Driven Development (TDD) approach can significantly reduce the number of bugs that make it to production. Testing provides many other benefits, like the freedom to refactor large parts of a system without (as much) fear of breaking things.

Everybody has a testing environment. Some people are lucky enough enough to have a totally separate environment to run production in.

— Papa Devops (@stahnma) August 21, 2015

With all of the benefits of testing, it’s still challenging to continually test applications. If you are looking to start learning how to test Laravel applications or you want to expand your skills here is a list of great resources to help you:

The Official Documentation


The official Laravel documentation is arguably the most complete testing guide that ships with a PHP framework. Not only does the guide itself make it very easy to start testing Laravel applications, but the framework itself also provides essential tools that take away the excuses of not testing. The most important features to make testing easier—that ship with Laravel—include database migrations for testing, factories, and mocking/fakes.

This first resource is obvious, but those new to Laravel and testing applications, stop by the documentation first. As a companion to the documentation, watch the Laracasts video Laravel From Scratch: Testing 101 for an overview of testing Laravel.

Laravel Dusk


Laravel Dusk is a browser testing package that works with >= Laravel 5.4. The Dusk documentation is part of the official Laravel documentation, but it’s worth mentioning separately because it is a recent addition to the Laravel testing tools. Dusk doesn’t require Selenium but uses the standalone ChromeDriver—which ships with the package.

Dusk allows you to test dynamic JavaScript applications with convenient browser abstractions and PHPUnit assertions. Before Laravel 5.4 full browser testing automation wasn’t possible without third party packages. This is another example of the Laravel framework facilitating testing and making it convenient for developers to get started.

The Orchestral Testbench Component


The Orchestral Testbench package is a testing helper for Laravel package development. According to the readme file, the Orchestral Testbench package:

…is a simple package that has been designed to help you write tests for your Laravel package, especially when there is routing involved.

The Laracasts Laravel Behat Extension


Behat is the defacto tool for Behavior-Driven Development (BDD) in the PHP community, and this package can help you get started with Behat and Laravel quickly. Before Laravel Dusk was available, full browser testing automation was only possible with third party packages and tools.

Although Dusk is now available, Behat might be a tool you prefer for acceptance testing if you prefer the BDD flavor of testing with Cucumber. Laracasts provides a lesson on using Behat,Laravel 5 and Behat: BFFs, which will help you get started with Behat 3 and Laravel 5.



phpspec is a tool for writing BDD Specifications in PHP. The interesting thing about phpspec is how it guides you through small steps in writing test specifications, then making them pass. Learning phpspec can open your mind to a new way of testing.

You can learn how to get started with the phpspec manual. Laracasts has an introduction video to compliment the documentation. phpspec is a great tool for testing any PHP project, including Laravel packages.

phpspec Laravel Extension


phpspec Laravel Extension helps you test Laravel applications with phpspec:

This extension provides you with a bootstrapped Laravel environment when writing your phpspec tests.

Learning phpspec is a prerequisite for using this package.

Let’s Build a Forum with Laravel and TDD


The Build a Forum with Laravel and TDD series is only available to subscribers, but a the time of this writing there are 58 lessons on building a forum with Laravel and Test-Driven Development. This is one of the most complete tutorials on testing with Laravel and TDD. Even if you exhaust the generous number of free resources first, this is a great way to learn more about TDD with Laravel.

Test-Driven Laravel


Test-Driven Laravel is a video series by Adam Wathan which provides a thorough look into testing Laravel applications. This course is not free, but as of this writing, you could still get early access. The course has many hours of courses with more still being added.

Adam Wathan initially gave a presentation on Test-Driven Laravel at ZendCon and then condensed his talk into a screencast you can watch online. We’ve also reviewed this course on Laravel News.

Spatie Laravel Packages


Spatie provides many Laravel packages, and they continue to ship new packages to the community. The packages contain a wealth of testing source code and are a good reference to help you learn how to test Laravel packages. Some packages have a dependency on the aforementioned Orchestral Testbench, providing you with some examples of using Testbench in action.

Spatie packages also have Continuous Integration with Travis CI (laravel-backup example). The murze.be blog provides Laravel tips and tricks on package development and new package announcements being released by Spatie.

The Ruby on Rails Tutorial Book


This resource is a bit of a wildcard. While not PHP or Laravel related, this free online book is chock-full of real-world testing examples you can apply to your projects. It starts picking up testing features in Chapter 3.3.

Even if you don’t care about Ruby or Rails, you will be hard-pressed to find better testing material on how to write web application tests, including the theory behind what to test and how to test it. You can follow along or just read through the material to get some great testing insight and inspiration.

Test Driven Development: By Example


Test Driven Development: By Example is considered by many a classic text on TDD. While the examples are not written in PHP, the book covers an expansive list of TDD patterns and practices and will provide beginners a good background on TDD with some practical examples.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.


Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Version 4 of Tinkerwell is available now. Get the most popular PHP scratchpad with all its new features and simplify your development workflow today.

Visit Tinkerwell
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo


The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo


Providing innovation and stability to ensure your web application succeeds.

Shift logo


Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

LoadForge logo


Easy, affordable load testing and stress tests for websites, APIs and databases.

Paragraph logo


Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
Bacancy - Staff Augmentation logo

Bacancy - Staff Augmentation

Leave your web app development hustles to the leading IT Staff Augmentation Service Providers. Choose from an extensive pool of 1050+ developers and give yourself the sigh of success you deserve with Bacancy. Get In Touch Today!

Bacancy - Staff Augmentation
DocuWriter.ai logo


Save hours of manually writing Code Documentation, Comments & DocBlocks, Test suites and Refactoring.

Rector logo


Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies


The latest

View all →
October CMS v3.6 Ships Today, Full of New Features image

October CMS v3.6 Ships Today, Full of New Features

Read article
Laracon EU Videos are now out image

Laracon EU Videos are now out

Read article
Use Google's Gemini AI in Laravel image

Use Google's Gemini AI in Laravel

Read article
PhpStorm is getting a brand new terminal image

PhpStorm is getting a brand new terminal

Read article
Six Essential Plugins for Visual Studio Code image

Six Essential Plugins for Visual Studio Code

Read article
Modularize Your Laravel Application With the Modular Package image

Modularize Your Laravel Application With the Modular Package

Read article