Autogenerate http tests for laravel

2.0.0 2021-03-24 19:56 UTC

This package is auto-updated.

Last update: 2022-06-24 23:05:53 UTC


Latest Version on Packagist Software License Total Downloads

No more writing tests by hand =D

Just execute the command to record your actions as http tests

php artisan autohttptest:create


The command will intercept your requests and translate the response as a test.

When finished, your test will be saved in tests/Feature/

Demo in video


What does it test?

  • Request acting as same user
  • Make request using the same verb (GET,PUT,POST) with same arguments
  • Assert http response code
  • Assert errors
  • Assert redirection

Example code


namespace Tests\Feature;
use Tests\TestCase;

class SomethingTest extends TestCase
    public function testAutoHttpTest()
        ->post('home/something', [
            'name'         => 'a',
            'lastname'     => 'a',
            'city'         => '',
            'hobbies'   => '',
            'twitter_username' => 'a',

        ->post('home/something', [
            'name'              => 'asdfa',
            'lastname'          => 'asdfa',
            'country_id' => '1',
            'city'              => '',
            'hobbies'        => '',
            'twitter_username'      => 'asdfa',


Here we capture an unsuccessful post, with errors. Then, a successful post with redirection


Via Composer

$ composer require eduardoarandah/autohttptests

If you are using laravel < 5.4 add to providers in config/app.php



php artisan autohttptest:create

How does it work?

when you run php artisan autohttptest:create yourtest it intercepts all requests and responses through a middleware.

The request is then analyzed and transformed into a test in a file storage/autohttptests.txt

If you're curious, you can see the building of that file in real time with

tail -f storage/autohttptests.txt



The MIT License (MIT). Please see License File for more information.