Skip to content

Tool that can generate skeleton test classes from production code classes and vice versa.

License

Notifications You must be signed in to change notification settings

cyberpearuk/phpunit-skelgen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPUnit 8 Skeleton Generator

Build Status codecov Codacy Badge Packagist

phpunit-skelgen is a tool that can generate skeleton test classes from production code classes and vice versa.

This is a fork of the original sebastianbergmann/phpunit-skeleton-generator which was abondoned at ~v4 of PHPUnit, to provide support for PHPUnit 8 and PHP7.1.

This fork is maintained by www.cyberpear.co.uk.

Installation

Composer

Simply add a development dependency on cyberpearuk/phpunit-skelgen to your project using Composer:

    composer require --dev "cyberpearuk/phpunit-skelgen=*"

For a system-wide installation via Composer, you can run:

    composer global require "cyberpearuk/phpunit-skelgen=*"

Make sure you have ~/.composer/vendor/bin/ in your path.

Usage

CLI

./vendor/bin/phpunit-skelgen --ansi generate-test <namespace> <src-file> <test-class-name> <tst-file>

./vendor/bin/phpunit-skelgen --ansi generate-test "My\Namespace" "path/to/src/class" "My\Namespace\ClassNameTest" "/path/to/tests/class"

Assertion Annotations

phpunit-skelgen will generate a test case for each assertion defined in the methods doc comment. For example the below will generate 4 test cases:

    /**
     * @assert (0, 0) == 0
     * @assert (0, 1) == 1
     * @assert (1, 0) == 1
     * @assert (1, 1) == 2
     */
    public function add($a, $b) {
        return $a + $b;
    }

Maintainer

This repository is maintained by Black Pear Digital.

About

Tool that can generate skeleton test classes from production code classes and vice versa.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%