Download the PHP package hyperia/codecept-unittest-generator without Composer
On this page you can find all versions of the php package hyperia/codecept-unittest-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hyperia/codecept-unittest-generator
More information about hyperia/codecept-unittest-generator
Files in hyperia/codecept-unittest-generator
Package codecept-unittest-generator
Short Description Unit test generator from annotations.
License MIT
Homepage https://github.com/hyperia-sk/codecept-unittest-generator
Informations about the package codecept-unittest-generator
Codecept UnitTest generator
This package allows you to generate PHPUnit tests from annotations, which you can write in your methods documentation.
- Basic usage of this package is to generate your tests skeleton and basic tests.
- You must check and complete all tests you generate, including the most basic methods.
- Files to parse must declare one class, abstract class, trait or interface to be accepted.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json.
Configuration
enable UnitGenerator
extension in base /codeception.yml
config file:
Usage
./vendor/bin/codecept generate:unit
Annotations
This annotation use some parameters:
-
phpunit_assertion_method: It is the PHPUnit assertion method you want ot use (like assertEquals, assertInstanceOf, assertTrue ...).
-
expectation: The method return expected value. Some PHPUnit methods does not need it (like assertTrue), so in those cases, it can be null.
- parameters: The method parameters.
See this example, we want to auto generate some simple test for this method:
Those annotations will create basic PHPUnit tests:
Getter and setter annotation
Those two annotations will allow you to auto-generate tests for simple getter / setter. Your getter / setter needs to be named like the following:
PHPUnit Generator has an "auto" option: If you activate it, it will search for the property when it find a method beginning with "get" or "set", and if the property exists, it will generate tests.
Private or protected method
If the method to test is private or protected, PHPUnit Generator will access the method with PHP ReflectionClass.
Requirements
UnitGenerator needs the following components to run:
- Codeception UnitGenerator is a module for Codeception. It will need a running version of this tool.
- Phpunit-generator package.
All versions of codecept-unittest-generator with dependencies
codeception/codeception Version ^2.2.0
paulthebaud/phpunit-generator Version 1.*