PHPackages                             parvej-mahmud/laravel-tdd-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. parvej-mahmud/laravel-tdd-generator

ActiveLibrary[Testing &amp; Quality](/categories/testing)

parvej-mahmud/laravel-tdd-generator
===================================

Automatically generate comprehensive TDD files for Laravel modules including models, controllers, migrations, and routes

01PHP

Since Aug 4Pushed 9mo agoCompare

[ Source](https://github.com/Parvej-Mahmud/tdd-generator)[ Packagist](https://packagist.org/packages/parvej-mahmud/laravel-tdd-generator)[ RSS](/packages/parvej-mahmud-laravel-tdd-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel TDD Generator
=====================

[](#laravel-tdd-generator)

A powerful Laravel package that automatically generates comprehensive Test-Driven Development (TDD) files for any given module or feature. This package creates well-structured test files for models, controllers, migrations, and routes with a single command.

Features
--------

[](#features)

- 🚀 **One Command, Complete TDD Suite**: Generate all test files for a module with one command
- 🧪 **Comprehensive Test Coverage**: Creates tests for models, controllers, migrations, and routes
- 🎯 **Smart Test Generation**: Automatically detects common patterns and generates appropriate tests
- 🔧 **Highly Customizable**: Customizable stubs and configurations
- 📝 **Best Practices**: Follows Laravel testing best practices and conventions
- 🏗️ **Multiple Test Types**: Supports unit, feature, and integration tests
- 🔒 **Security Aware**: Includes authentication and authorization tests

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require parvej-mahmud/laravel-tdd-generator --dev
```

Publish the configuration file:

```
php artisan vendor:publish --provider="ParvejMahmud\LaravelTddGenerator\TddGeneratorServiceProvider" --tag="config"
```

Optionally, publish the stub files for customization:

```
php artisan vendor:publish --provider="ParvejMahmud\LaravelTddGenerator\TddGeneratorServiceProvider" --tag="stubs"
```

Usage
-----

[](#usage)

### Generate Complete TDD Suite

[](#generate-complete-tdd-suite)

Generate all test files for a module:

```
php artisan make:tdd Post
```

This creates:

- `tests/Unit/PostTest.php` - Model tests
- `tests/Feature/PostControllerTest.php` - Controller tests
- `tests/Unit/PostsMigrationTest.php` - Migration tests
- `tests/Feature/PostRouteTest.php` - Route tests

### Generate Specific Test Types

[](#generate-specific-test-types)

Generate only specific test types:

```
# Generate only model tests
php artisan make:tdd Post --model

# Generate only controller tests
php artisan make:tdd Post --controller

# Generate multiple specific types
php artisan make:tdd Post --model --controller
```

### Individual Commands

[](#individual-commands)

You can also use individual commands for more control:

```
# Generate model test only
php artisan make:model-test Post

# Generate controller test only
php artisan make:controller-test PostController

# Generate migration test only
php artisan make:migration-test posts

# Generate route test only
php artisan make:route-test Post
```

### Command Options

[](#command-options)

- `--model`: Generate model tests
- `--controller`: Generate controller tests
- `--migration`: Generate migration tests
- `--routes`: Generate route tests
- `--all`: Generate all test types (default behavior)
- `--force`: Overwrite existing files

Generated Tests
---------------

[](#generated-tests)

### Model Tests

[](#model-tests)

The generated model tests include:

- ✅ CRUD operations (Create, Read, Update, Delete)
- ✅ Fillable attributes validation
- ✅ Required fields validation
- ✅ Relationships testing
- ✅ Timestamps verification
- ✅ Factory integration

### Controller Tests

[](#controller-tests)

The generated controller tests include:

- ✅ All CRUD endpoints (index, show, store, update, destroy)
- ✅ Request validation testing
- ✅ Authentication and authorization
- ✅ Error handling (404, 422, etc.)
- ✅ Pagination testing
- ✅ Search functionality

### Migration Tests

[](#migration-tests)

The generated migration tests include:

- ✅ Table creation verification
- ✅ Column existence and types
- ✅ Primary key validation
- ✅ Timestamps verification
- ✅ Constraints testing
- ✅ Data insertion capabilities

### Route Tests

[](#route-tests)

The generated route tests include:

- ✅ Route existence verification
- ✅ HTTP method validation
- ✅ URL generation testing
- ✅ Middleware verification
- ✅ Authentication requirements
- ✅ Error handling

Configuration
-------------

[](#configuration)

The package comes with a comprehensive configuration file. Here are the key options:

```
// config/tdd-generator.php

return [
    // Default test types to generate
    'default_types' => [
        'model' => true,
        'controller' => true,
        'migration' => true,
        'routes' => true,
    ],

    // Test namespaces
    'namespaces' => [
        'unit' => 'Tests\\Unit',
        'feature' => 'Tests\\Feature',
    ],

    // Authentication requirements
    'auth_required' => [
        'store' => true,
        'update' => true,
        'destroy' => true,
    ],
];
```

Customizing Stubs
-----------------

[](#customizing-stubs)

You can customize the generated test files by publishing and modifying the stub files:

```
php artisan vendor:publish --provider="ParvejMahmud\LaravelTddGenerator\TddGeneratorServiceProvider" --tag="stubs"
```

The stub files will be published to `resources/stubs/tdd-generator/` where you can modify them to match your project's coding standards.

Examples
--------

[](#examples)

### Basic Usage

[](#basic-usage)

```
# Generate complete TDD suite for a User module
php artisan make:tdd User

# Generate tests for an API resource
php artisan make:tdd Product --controller --routes

# Force overwrite existing files
php artisan make:tdd Order --force
```

### Advanced Usage

[](#advanced-usage)

```
# Generate tests for a complex module with custom options
php artisan make:tdd BlogPost --all

# Generate only unit tests
php artisan make:tdd Category --model --migration

# Generate only feature tests
php artisan make:tdd Comment --controller --routes
```

Best Practices
--------------

[](#best-practices)

1. **Run Tests First**: Always run the generated tests to ensure they pass with your current setup
2. **Customize as Needed**: Modify the generated tests to match your specific business logic
3. **Use Factories**: Ensure you have model factories set up for better test data generation
4. **Follow TDD**: Use the generated tests as a starting point for your TDD workflow
5. **Keep Tests Updated**: Update tests when you modify your models, controllers, or routes

Requirements
------------

[](#requirements)

- PHP ^8.1
- Laravel ^10.0|^11.0
- PHPUnit ^10.0

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

Support
-------

[](#support)

If you encounter any issues or have questions, please [open an issue](https://github.com/parvej-mahmud/laravel-tdd-generator/issues) on GitHub.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance41

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/aae3d630e96082352da4e31b3049957c5a4624ad117b4ef1ebbd016f031cacf2?d=identicon)[Parvej-Mahmud](/maintainers/Parvej-Mahmud)

---

Top Contributors

[![Parvej-Mahmud](https://avatars.githubusercontent.com/u/12599738?v=4)](https://github.com/Parvej-Mahmud "Parvej-Mahmud (4 commits)")

### Embed Badge

![Health badge](/badges/parvej-mahmud-laravel-tdd-generator/health.svg)

```
[![Health](https://phpackages.com/badges/parvej-mahmud-laravel-tdd-generator/health.svg)](https://phpackages.com/packages/parvej-mahmud-laravel-tdd-generator)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
