Laravel makes it super easy to add tests to your application. There may be times where you want to create a quick PHPUnit test to confirm your application URL's return a 200 request.

I'm not suggesting that you only include tests that check all your route applications; however, this will be better than not including any tests at all.

If you wish to add these tests to your Laravel application you can start off by deleting the PHPUnit file located at tests/Features/ExampleTest.php and then run the following command to create a new test:

php artisan make:test RouteTest.php

This will create a new file located at tests/Features/RouteTest.php, inside of this file you can add the following:


namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class RouteTest extends TestCase
     * A basic test example.
     * @return void
    public function testRoutes()
        $appURL = env('APP_URL');

        $urls = [

        echo  PHP_EOL;

        foreach ($urls as $url) {
            $response = $this->get($url);
            if((int)$response->status() !== 200){
                echo  $appURL . $url . ' (FAILED) did not return a 200.';
            } else {
                echo $appURL . $url . ' (success ?)';
            echo  PHP_EOL;


Make sure to enter your application URL's in the $urls array above. Lastly, run the following in your command prompt:


And this will run PHP unit and check that all the application routes inside of the $urls array return a status code of 200, you will see an output that looks similar to the following:

Simple Laravel Route Tests

And just like that you have some Simple Laravel Route tests in your application ;)


or Sign Up

Sign Up

or Login
Want to create your own SAAS?

I can teach you to create your own Software as a Service. Click here to learn more!

Visit SAAS Adventure!