PHPackages                             ahrmerd/laravel-test-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. ahrmerd/laravel-test-generator

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

ahrmerd/laravel-test-generator
==============================

The Ahrmerd/TestGenerator package is a Laravel command-line tool that automatically generates API and web tests for your Eloquent models. With just a few simple commands, you can quickly generate comprehensive test files that cover CRUD operations, validation, and other common use cases for your models. The package provides options to generate tests for all models in your application or for specific models, and supports overwriting existing test files with the --force option. Additionally, it automatically generates test content based on your model's form request classes, making it easy to ensure your tests reflect your application's validation rules. Speed up your Laravel testing workflow with the Ahrmerd/TestGenerator package

2.0(3y ago)52313[2 PRs](https://github.com/ahrmerd/laravel-test-generator/pulls)MITPHPPHP ^8.1

Since Apr 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ahrmerd/laravel-test-generator)[ Packagist](https://packagist.org/packages/ahrmerd/laravel-test-generator)[ Docs](https://github.com/ahrmerd/laravel-test-generator)[ RSS](/packages/ahrmerd-laravel-test-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (13)Versions (6)Used By (0)

Ahrmerd/TestGenerator
=====================

[](#ahrmerdtestgenerator)

Ahrmerd/TestGenerator is a command-line tool for generating test files for Laravel models. It helps you quickly generate feature tests for your Eloquent models to facilitate automated testing in your Laravel application.

Features
--------

[](#features)

- Generate test files for individual models or all models in your Laravel application
- Automatically generate test methods for common CRUD operations (create, read, update, delete)
- Provides a template for writing custom test methods for additional testing scenarios
- Automatically generates test file names based on the model name
- Supports Laravel Form Request classes for extracting validation rules
- Option to overwrite existing test files with a `--force` flag

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

[](#installation)

You can install Ahrmerd/TestGenerator via Composer using the following command:

```
composer require ahrmerd/laravel-test-generator --dev
```

the tests generated by the package requires the Pest's Laravel plugin to work. To start using Pest's Laravel plugin, you need to require this plugin via Composer.

```
composer require pestphp/pest-plugin-laravel --dev
```

Once installed, run the following Artisan command to publish the configuration file:

```
php artisan vendor:publish --tag=TestGenerator-config
```

Compatibility
-------------

[](#compatibility)

This package is compatible with Laravel 10 and above.

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

[](#configuration)

You can configure the behavior of the TestGenerator package using the laravel-TestGenerator.php config file. Here are the available options:

### - ignore\_models

[](#--ignore_models)

An array of models that should be ignored when generating tests when --all option is passed. Models listed in this array will not have tests generated for them. by default, it ignores creating test test for the user model. For example:

```
    'ignore_models' => [
        'User', 'Post'
    ],
```

### default

[](#default)

The default type of tests to generate. You can specify either 'api', 'web', 'both', or null (default). If set to 'api', only API tests will be generated by default. If set to 'web', only web tests will be generated by default. If set to 'both', both API and web tests will be generated by default.

Usage
-----

[](#usage)

Once installed, you can use Ahrmerd/TestGenerator via the command-line interface (CLI). Here are some examples:

### - Generate tests for a specific model:

[](#--generate-tests-for-a-specific-model)

```
 php artisan generate:tests ModelName
```

This command will generate test files for the ModelName model in your Laravel application. The test files will contain test methods for common CRUD operations such as create, read, update, and delete, based on the --api or --web options provided (default is --api). You can also add custom test methods in the generated test files.

### - Generate tests for all models:

[](#--generate-tests-for-all-models)

```
php artisan generate:tests --all
```

This command will generate test files for all models in your Laravel application. Each test file will contain test methods for common CRUD operations, based on the --api or --web options provided (default is --api), as well as a template for writing custom test methods for additional testing scenarios.

### - Overwrite existing test files:

[](#--overwrite-existing-test-files)

```
php artisan generate:tests ModelName --force
```

By default, Ahrmerd/TestGenerator will not overwrite existing test files. However, you can use the --force flag to overwrite existing test files if needed. Please use this option with caution, as it will overwrite any existing test files for the specified model.

### - Specify type of tests to generate:

[](#--specify-type-of-tests-to-generate)

```
php artisan generate:tests ModelName --api
```

This command will generate test files for the ModelName model with test methods specifically for testing API routes and functionality. You can also use the --web option to generate test methods for testing web routes and functionality (default will generate for both api and web).

Note:
-----

[](#note)

-You can use any combination of options (--api, --web, --force) to customize the generated test files as per your requirements. -You can customize the generated test methods or add your own custom test methods in the generated test files to suit your specific testing needs. -Pest PHP is required for the generated tests to work. Make sure you have Pest PHP installed and configured in your Laravel project before running the generate:tests command

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

[](#contributing)

Contributions to Ahrmerd/TestGenerator are welcome! If you would like to contribute, please follow the standard GitHub Fork &amp; Pull Request workflow.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.6% 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.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

1122d ago

Major Versions

1.1 → 2.02023-04-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/c290078752ce17d11d3d3b41da1845161bd0615c055b0808f7a553065716a7c5?d=identicon)[trikss](/maintainers/trikss)

---

Top Contributors

[![ahrmerd](https://avatars.githubusercontent.com/u/33347856?v=4)](https://github.com/ahrmerd "ahrmerd (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")[![andychukse](https://avatars.githubusercontent.com/u/12896611?v=4)](https://github.com/andychukse "andychukse (1 commits)")

---

Tags

testlaravelgeneratorahrmerd

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ahrmerd-laravel-test-generator/health.svg)

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

###  Alternatives

[infyomlabs/laravel-generator

InfyOm Laravel Generator

3.8k2.3M13](/packages/infyomlabs-laravel-generator)

PHPackages © 2026

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