PHPackages                             simplemachineorg/generate-laravel-test - 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. simplemachineorg/generate-laravel-test

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

simplemachineorg/generate-laravel-test
======================================

Use AI to dynamically create a test for a PHP Class in your application.

0.1.2(1y ago)177MITPHPPHP ^8.1

Since Feb 1Pushed 1y agoCompare

[ Source](https://github.com/simplemachineorg/generate-laravel-test)[ Packagist](https://packagist.org/packages/simplemachineorg/generate-laravel-test)[ Docs](https://github.com/simplemachineorg/generate-laravel-test)[ GitHub Sponsors](https://github.com/iambateman)[ RSS](/packages/simplemachineorg-generate-laravel-test/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (13)Versions (9)Used By (0)

Use AI to dynamically create a test for a PHP Class in your application.
========================================================================

[](#use-ai-to-dynamically-create-a-test-for-a-php-class-in-your-application)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f1c9a15577d8e74b0137ad562b2362af65eb35a211d12cf2c8fc6e67457f9dbf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696d706c656d616368696e656f72672f67656e65726174652d6c61726176656c2d746573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simplemachineorg/generate-laravel-test)[![GitHub Tests Action Status](https://camo.githubusercontent.com/643069c3f7066b84e9ea003763211c53b66b405c5b91ae9bd9c96f9d79b1e9be/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73696d706c656d616368696e656f72672f67656e65726174652d6c61726176656c2d746573742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/simplemachineorg/generate-laravel-test/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/148c1db81db07c14ea3a6a7ebd84cbc788f24e0e5cece6845db2f92437681084/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73696d706c656d616368696e656f72672f67656e65726174652d6c61726176656c2d746573742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/simplemachineorg/generate-laravel-test/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/d22cc8436c8c62d377460b7f43e78006d319380cee6de66e64ffa65247326cb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696d706c656d616368696e656f72672f67656e65726174652d6c61726176656c2d746573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simplemachineorg/generate-laravel-test)

ALPHA
-----

[](#alpha)

This package is a work in progress and may have breaking changes.

Overview
--------

[](#overview)

It make it easy to quickly create Laravel tests using GPT. The package sends your code file to GPT along with some prompt instructions and saves a draft test in a \_draft folder.

Every generated test needs adjustment since GPT doesn't know everything about the app, but it's a helpful starting point. In practice, it's easier to write more tests when the scaffolding work is automated.

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

[](#installation)

Issue this command...

```
composer require simplemachineorg/generate-laravel-test`

```

Then, set your API Key in env...

```
GENERATE_TEST_OPENAI_API_KEY=

```

Optionally, you can publish the config file using...

```
php artisan vendor:publish --tag="generate_laravel_test-config"

```

Using this package
------------------

[](#using-this-package)

Issue this command to use AI to generate a test...

```
php artisan generate:test

```

It will ask you to search for a PHP file in your code base and use that to generate the test.

Adding custom notes about the app
---------------------------------

[](#adding-custom-notes-about-the-app)

You can create a file which renders custom notes about the app in every request, so that the test generator is more intelligent about your specific setup. By default, create a view inside `resources/views/utility/generate-test-custom-notes.blade.php` and write your notes. You can optionally change the location of the file in the config.

Publishing Config (optional)
----------------------------

[](#publishing-config-optional)

```
php artisan vendor:publish --tag=":generate_laravel_test-config"

```

This is the default config file...

```
return [

    /*
    |--------------------------------------------------------------------------
    | API Key
    |--------------------------------------------------------------------------
    |
    | An OpenAI API key is required to use this package.
    |
    */
    'open_ai_api_key' => env('GENERATE_TEST_OPENAI_API_KEY'),

    /*
    |--------------------------------------------------------------------------
    | Custom notes Path (optional)
    |--------------------------------------------------------------------------
    |
    | You can create a blade file with extra notes which will get placed
    | inside each request so the AI knows more about your specific app.
    |
    */
    'custom_notes' => env('GENERATE_TEST_EXTRA_NOTES_PATH', 'utility.generate-test-custom-notes'),

    /*
    |--------------------------------------------------------------------------
    | Comment Out code before adding to the project
    |--------------------------------------------------------------------------
    |
    | If PHP detects code inside the project with a syntax error, it will
    | throw an exception until you fix it. So you can comment out all code
    | to avoid runtime errors.
    |
    */
    'comment_out' => env('GENERATE_TEST_COMMENT_OUT', true),

    /*
    |--------------------------------------------------------------------------
    | Default Model
    |--------------------------------------------------------------------------
    |
    | The default OpenAI model used for creating tests.
    |
    */
    'default_model' => env('GENERATE_TEST_DEFAULT_MODEL', 'gpt-4o'),

    /*
    |--------------------------------------------------------------------------
    | TEST RUNNER
    |--------------------------------------------------------------------------
    |
    | Either 'pest' or 'phpunit'
    |
    */
    'runner' => env('GENERATE_TEST_RUNNER', 'pest'),

    /*
    |--------------------------------------------------------------------------
    | PATH TO STORE DRAFT FILES
    |--------------------------------------------------------------------------
    |
    | Where should we put the files once they are processed?
    | Note: the files will not be runnable PHP immediately.
    |
    |
    */
    'draft_test_file_path' => env('GENERATE_TEST_FILE_PATH', 'tests/Feature/_draft'),

];
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~49 days

Total

8

Last Release

632d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/718a9024fa0c4215a78372fe3c28a6377b93071855417ad642c0513b86c54b89?d=identicon)[iambateman](/maintainers/iambateman)

---

Top Contributors

[![iambateman](https://avatars.githubusercontent.com/u/1709997?v=4)](https://github.com/iambateman "iambateman (17 commits)")

---

Tags

laraveliambatemangenerate-laravel-test

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/simplemachineorg-generate-laravel-test/health.svg)

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

###  Alternatives

[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-site-search

A site search engine

300129.1k](/packages/spatie-laravel-site-search)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-visit

Quickly visit any route of your Laravel app

15614.6k](/packages/spatie-laravel-visit)

PHPackages © 2026

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