Skip to content

JIT PHPUnit Test Generation. Build Unit tests for diverse PHPUnit versions from a master set of PHPUnit tests.

License

Notifications You must be signed in to change notification settings

NathanGibbs3/cptgenerate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cptgenerate -- JIT PHPUnit Test Generation Build Status

Build Unit tests for diverse PHPUnit versions from a master set of PHPUnit tests.

Generates a single set of Unit tests based on supplied PHPUnit version or multiple test sets that can be run by PHPUnit based on installed PHP version.

Build Status

master Build Status devel Build Status

This project enables developers to:

  1. Build with all default PHP Major.Minor versions available on travis-ci.
  2. Build with default PHP/PHPUnit combinations avaliable on travis-ci.
  3. Maintain one set of Unit tests.
  4. Spend less time maintaining Unit tests.
  5. Spend more time writing code. 😄

History:

While working on BASE, we ended up with test sets for 3 different versions of PHPUnit. Occasionally, builds failed or did not have uniform code coverage as maintaining the Unit test sets was a manual process. Local testing in VM's also raised issues with PHP/PHPUnit combinations not seen via CI. Additionally, ~90% of the code in each Unit test set was identical.

The differnences between each test set were:

  1. Class defines.
    1. Namespaced.
    2. Non-Namespaced.
  2. Test fixture defines.
    1. Typehinted.
    2. Non-Typehinted.

The solution:

cptgenerate which builds, from a master set of PHPUnit tests, a set of tests compatible with the PHPUnit version used in the test environment. Basically, JIT PHPUnit Test generation.

Usage:

Command Line Options are space sepearated. All locations are relative to execution dir.

Options:

  1. Location of Master Test Set ( defaults to tests/php );

  2. Location of Test Build ( defaults to tests/PhpUnit );

    If set to "multi" will search for multiple Test set locations formated as tests/phpX.X

    Dir Namespace Typehint
    tests/php5.2 No No
    tests/php7.1 Yes Yes
    tests/php*.* Yes No
  3. PHPUnit Version ( defaults to 0.0.0 )

Examples:

Command Master Tests Generated Tests
php -f ./tests/phptestgen.php In ./tests/php In ./tests/PhpUnit
php -f ./tests/phptestgen.php LocA In ./tests/LocA In ./tests/PhpUnit
php -f ./tests/phptestgen.php LocA LocB In ./tests/LocA In ./tests/LocB
php -f ./tests/phptestgen.php LocA multi In ./tests/LocA In ./tests/php*.* with customizations.

With a PHPUnit version specified as ( X.Y.Z ), the above examples will generate customized tests.

PHPUnit Version Namespace Typehint
0.0.0 default value when not specified Yes No
< 4.8.28 No No
4.8.28+ to < 7.0 Yes No
7.0+ Yes Yes

Related Software

PHPUnit by @sebastianbergmann

About

JIT PHPUnit Test Generation. Build Unit tests for diverse PHPUnit versions from a master set of PHPUnit tests.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published