Skip to content

PHP Test Generator automates PHPUnit test creation for PHP projects. It generates test scaffolding by scanning source code, supports custom directories, and allows selective test regeneration. Ideal for developers aiming to enhance test coverage efficiently.

License

Notifications You must be signed in to change notification settings

stoufa06/generate-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenerateTests

This package helps automate the creation of PHPUnit test files for your PHP project. It scans specified source directories for PHP files and generates corresponding test classes.

Installation

To install the package, you’ll need Composer. Run the following command in your terminal:

composer require stoufa06/generate-tests --dev

Usage

After installing the package, use the generate-tests script from the command line to generate test files for your source code.

Command Line Options

The script supports several command line options to customize its behavior:

  • --src=<path>: Specify the source directory containing the PHP files for which tests should be generated. Default is src. If a relative path is provided, it will be resolved using the base directory.

  • --tests=<path>: Specify the output directory where the test files will be generated. Default is tests. If a relative path is provided, it will be resolved using the base directory.

  • --backup=<file>: Specify a file containing a list of test files that should always be regenerated. Default is backup_list.txt.

  • --exclude=<file>: Specify a file listing folders to exclude from test generation. Default is excluded_folders.txt.

  • --marker=<bool>: Enable or disable the check for a specific marker in test files. By default, only files containing a '// Generated by script' comment will be regenerated if they already exist.

  • --baseDir=<path>: Specify the base directory to resolve relative paths. Default is the current working directory. If provided, all relative paths for src, tests, backup, and exclude will be based on this directory.

Example Usage

vendor/bin/generate-tests --src=src --tests=tests --backup=backup_list.txt --exclude=excluded_folders.txt --marker=1 --baseDir=/path/to/base

This command will generate test files for all PHP files within the src directory, output them to the tests directory, check against backup_list.txt and excluded_folders.txt for any specific rules, and regenerate any previously scripted files containing the marker.

Contributing

Feel free to submit issues or pull requests. Contributions are welcome!

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

PHP Test Generator automates PHPUnit test creation for PHP projects. It generates test scaffolding by scanning source code, supports custom directories, and allows selective test regeneration. Ideal for developers aiming to enhance test coverage efficiently.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages