gessyken / laravel-test-accelerator
A powerful Laravel package to accelerate the development and testing process of your applications
Fund package maintenance!
gessyken
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 1
pkg:composer/gessyken/laravel-test-accelerator
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2025-10-13 16:00:50 UTC
README
A powerful Laravel package to accelerate the development and testing process of your applications. Laravel Test Accelerator provides intelligent tools to automatically generate tests, analyze code coverage, and optimize your test performance.
โจ Features
- ๐ Automatic Test Generation - Create unit and feature tests with just a few clicks
- ๐ Code Coverage Analysis - Identify untested areas of your application
- โก Performance Optimization - Detect and resolve slow tests
- ๐ค AI Integration - Use artificial intelligence to generate intelligent test cases
- ๐ Detailed Reports - Get comprehensive insights into your test quality
- ๐ง Flexible Configuration - Customize behavior according to your needs
๐ฆ Installation
You can install the package via Composer:
composer require gessyken/laravel-test-accelerator
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="laravel-test-accelerator-config"
The configuration file will be published to config/laravel-test-accelerator.php
:
<?php return [ 'ai_provider' => env('TEST_ACCELERATOR_AI_PROVIDER', 'openai'), 'ai_api_key' => env('TEST_ACCELERATOR_AI_API_KEY'), 'test_paths' => [ 'tests/Unit', 'tests/Feature', ], 'ignore_directories' => [ 'vendor', 'node_modules', 'storage', ], 'benchmark' => [ 'slow_threshold' => 1000, // ms 'memory_threshold' => 1024, // KB ], ];
Environment Variables
Add these variables to your .env
file:
TEST_ACCELERATOR_AI_PROVIDER=openai TEST_ACCELERATOR_AI_API_KEY=your_api_key_here
๐ Usage
Test Generation
Generate tests for a specific file:
php artisan test:generate app/Models/User.php
Generate tests for an entire directory:
php artisan test:generate app/Services/
Use AI to generate smarter tests:
php artisan test:generate app/Models/User.php --ai
Coverage Analysis
Analyze your test coverage:
php artisan test:coverage
Generate a detailed HTML report:
php artisan test:coverage --report
Set a minimum coverage threshold:
php artisan test:coverage --threshold=80
Performance Benchmark
Analyze your test performance:
php artisan test:benchmark
Programmatic Usage
use KENCODE\LaravelTestAccelerator\Facades\LaravelTestAccelerator; // Generate tests LaravelTestAccelerator::generateTests('app/Models/User.php'); // Analyze coverage $coverage = LaravelTestAccelerator::analyzeCoverage(); // Get performance statistics $stats = LaravelTestAccelerator::getPerformanceStats();
๐ Usage Examples
Example 1: Test Generation for an Eloquent Model
// app/Models/User.php class User extends Authenticatable { protected $fillable = ['name', 'email', 'password']; public function posts() { return $this->hasMany(Post::class); } public function getFullNameAttribute() { return $this->first_name . ' ' . $this->last_name; } }
After running php artisan test:generate app/Models/User.php
, you'll get:
// tests/Unit/UserTest.php class UserTest extends TestCase { use RefreshDatabase; /** @test */ public function it_can_create_a_user() { $user = User::factory()->create(); $this->assertNotNull($user); } /** @test */ public function it_can_get_full_name_attribute() { $user = User::factory()->create([ 'first_name' => 'John', 'last_name' => 'Doe' ]); $this->assertEquals('John Doe', $user->full_name); } /** @test */ public function it_has_many_posts() { $user = User::factory()->create(); $post = Post::factory()->create(['user_id' => $user->id]); $this->assertTrue($user->posts->contains($post)); } }
Example 2: Coverage Analysis
$ php artisan test:coverage +------------------+----------+---------+ | File | Coverage | Status | +------------------+----------+---------+ | app/Models/User | 95% | โ Good | | app/Services/... | 67% | โ ๏ธ Low | | app/Http/... | 89% | โ Good | +------------------+----------+---------+ Overall coverage: 84%
๐งช Testing
Run the package tests:
composer test
Run tests with coverage:
composer test-coverage
๐ Reports and Metrics
The package generates several types of reports:
- HTML Coverage Report - Interactive coverage visualization
- Performance Report - Identification of slow tests
- Analysis Report - Improvement suggestions
๐ง Advanced Configuration
Customizing Test Templates
You can customize test generation templates by publishing the views:
php artisan vendor:publish --tag="laravel-test-accelerator-views"
CI/CD Integration
Add these commands to your CI pipeline:
# .github/workflows/tests.yml - name: Generate test coverage run: php artisan test:coverage --threshold=80 - name: Run performance benchmark run: php artisan test:benchmark
๐ค Contributing
Contributions are welcome! Please read our contributing guide for more details.
Local Development
- Clone the repository
- Install dependencies:
composer install
- Run tests:
composer test
- Create your feature branch
- Submit a Pull Request
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ Security
If you discover a security vulnerability, please send an email to gessyken@gmail.com instead of using the bug tracker.
๐ License
The Laravel Test Accelerator package is open-sourced software licensed under the MIT license.
๐จโ๐ป Author
Aurel KENNE
- GitHub: @gessyken
- Email: gessyken@gmail.com
- Website: https://accelerator.kencode.dev
๐ Acknowledgments
- Spatie for the Laravel package development tools
- Laravel for the amazing framework
- All contributors who make this project possible
โญ If this package helps you, please give it a star on GitHub!