https://github.com/nathangibbs3/cptgenerate
JIT PHPUnit Test Generation. Build Unit tests for diverse PHPUnit versions from a master set of PHPUnit tests.
https://github.com/nathangibbs3/cptgenerate
automation build-tool jit php phpunit phpunit-tests test-generation
Last synced: 3 months ago
JSON representation
JIT PHPUnit Test Generation. Build Unit tests for diverse PHPUnit versions from a master set of PHPUnit tests.
- Host: GitHub
- URL: https://github.com/nathangibbs3/cptgenerate
- Owner: NathanGibbs3
- License: gpl-2.0
- Created: 2019-05-03T03:43:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-28T18:16:08.000Z (almost 5 years ago)
- Last Synced: 2025-01-18T08:44:43.008Z (4 months ago)
- Topics: automation, build-tool, jit, php, phpunit, phpunit-tests, test-generation
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# cptgenerate -- JIT PHPUnit Test Generation [](https://travis-ci.com/NathanGibbs3/cptgenerate)
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 [](https://travis-ci.com/NathanGibbs3/cptgenerate)
devel [](https://travis-ci.com/NathanGibbs3/cptgenerate)## This project enables developers to:
1. Build with all default PHP Major.Minor versions available on travis-ci.
1. Build with default PHP/PHPUnit combinations avaliable on travis-ci.
1. Maintain one set of Unit tests.
1. Spend less time maintaining Unit tests.
1. Spend more time writing code. :smile:# History:
While working on [BASE](https://github.com/NathanGibbs3/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.
1. Non-Namespaced.
1. Test fixture defines.
1. Typehinted.
1. 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 );
1. Location of Test Build ( defaults to tests/PhpUnit );If set to "multi" will search for multiple Test set locations
formated as tests/phpX.XDir | Namespace | Typehint
---|---|---
tests/php5.2 | No | No
tests/php7.1 | Yes | Yes
tests/php*.* | Yes | No1. 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](https://github.com/sebastianbergmann/phpunit) by
[@sebastianbergmann](https://github.com/sebastianbergmann)