Download the PHP package ahrmerd/laravel-test-generator without Composer
On this page you can find all versions of the php package ahrmerd/laravel-test-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ahrmerd/laravel-test-generator
More information about ahrmerd/laravel-test-generator
Files in ahrmerd/laravel-test-generator
Package laravel-test-generator
Short Description 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
License MIT
Homepage https://github.com/ahrmerd/laravel-test-generator
Informations about the package laravel-test-generator
Ahrmerd/TestGenerator
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
- 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
You can install Ahrmerd/TestGenerator via Composer using the following command:
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.
Once installed, run the following Artisan command to publish the configuration file:
Compatibility
This package is compatible with Laravel 10 and above.
Configuration
You can configure the behavior of the TestGenerator package using the laravel-TestGenerator.php config file. Here are the available options:
- 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:
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
Once installed, you can use Ahrmerd/TestGenerator via the command-line interface (CLI). Here are some examples:
- Generate tests for a specific model:
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:
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:
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:
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:
-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
Contributions to Ahrmerd/TestGenerator are welcome! If you would like to contribute, please follow the standard GitHub Fork & Pull Request workflow.
All versions of laravel-test-generator with dependencies
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version ^10.0