Download the PHP package schranz/test-generator without Composer
On this page you can find all versions of the php package schranz/test-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download schranz/test-generator
More information about schranz/test-generator
Files in schranz/test-generator
Package test-generator
Short Description A cli tool which generates unit tests.
License MIT
Informations about the package test-generator
PHP Test Generator
This project make usages of PHPStan (WIP) and PHPParser to generate test cases for a given PHP File by parsing its AST.
Why?
With static code analyzer it is possible to generate tests which where mostly forgotten. The target of the project is not to generate a whole test cases instead it should generate the most boilerplate code of the test case and tell which method for the class methods should be implemented.
So example if we have a method like the following:
If you are using code coverage you will get 100% when you are testing:
But as ?string can be seen as an union type of string|null the testcase for null type is missing:
The project target is to already generate also the boilerplate for that test case.
Installation
Config
Create a new tests/generator-config.php file:
See Config.php for all options.
It is recommended to also configure in the projects phpunit.xml the failOnIncomplete to true:
So generated tests fail automatically and require adjustments and review by the developer.
Usage
All versions of test-generator with dependencies
nikic/php-parser Version ^4.18 || ^5.0
symfony/filesystem Version ^5.4 || ^6.0 || ^7.0
symfony/string Version ^5.4 || ^6.0 || ^7.0
symfony/process Version ^5.4 || ^6.0 || ^7.0