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

dev-main 2025-09-08 13:03 UTC

This package is auto-updated.

Last update: 2025-10-13 16:00:50 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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

  1. Clone the repository
  2. Install dependencies: composer install
  3. Run tests: composer test
  4. Create your feature branch
  5. 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

๐Ÿ™ 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!