boggybot / laravel-test-generator
Generate laravel tests stubs from registered routes.
0.1.2
2020-02-27 01:23 UTC
Requires
- php: ^7.1
- illuminate/support: ~5.0|~6.0|~7.0
This package is auto-updated.
Last update: 2025-06-27 12:38:10 UTC
README
If you have not been writing any tests for your Laravel app, and need a way to scaffold your integration tests, this tool is for you.
How it works?
- Generator scans your registered routes
- Generates Test for each controller
- Generates stubs for each one of your controller actions
- You will need to then fill in the stubs with whatever logic your app needs.
Sample Result
<?php
namespace Tests\Amazing\Dashboard\DashboardTest;
use Tests\TestCase;
class DashboardTest extends TestCase
{
/** @see \App\Http\Controllers\Dashboard\DashboardController::index() */
public function test_get_dashboard_index()
{
//$response = $this->get(route('dashboard.index', []));
//$response->assertOk();
}
////
}
How to use
composer require --dev boggybot/laravel-test-generator
php artisan generate:tests
App Namespace
By default, any matching registered route in the current project namespace qualifies. eg. App\
You can change which namespace for generator to scan.
php artisan generate:tests --app-namespace="AwesomeApp"
Test Namespace
By default, all tests will be written to 'tests/Acceptance' folder.
php artisan generate:tests --test-namespace="Tests\FeatureTests"
Customize Stubs
php artisan vendor:publish --tag=laravel-test-generator-stubs