peterdkc/test-runner

A consistent set of commands for running tests in your project.

Installs: 10 948

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

Type:package

1.0.7 2023-08-09 14:18 UTC

README

Test Runners provides a consistent set of composer commands to run, filter, and view coverage on your project's PHPUnit test suite.

Installation

Install the package via composer:

composer require --dev peterdkc/test-runners

Add the following as desired to your project's composer.json file in the scripts section:

"scripts": {
    "test": "PeterDKC\\TestRunner::test",
    "repeat": "PeterDKC\\TestRunner::repeatTest",
    "filter": "PeterDKC\\TestRunner::filterTests",
    "coverage-text": "PeterDKC\\TestRunner::coverageText",
    "coverage-clover": "PeterDKC\\TestRunner::coverageClover",
    "coverage-full": "PeterDKC\\TestRunner::coverageFull",
    "filter-coverage": "PeterDKC\\TestRunner::filterCoverage"
}

Install pcov according to the instructions found here in order to run test coverage.

Usage

Testing and running coverage normally can be run like any other composer scripts.

composer test

or

composer coverage-full

However, filter, repeat and filter-coverage require arguments

composer filter aTestNameOrClassToFilterTo
compsoer repeat 30 aTestFilterToRunThirtyTimes
compsoer filter-coverage aTestNameOrClassToFilterTo

Testing the package

Everything has to be done manually, since the runners cannot execute themselves.

vendor/bin/phpunit tests
  • tests contains the actual tests of the src/ directory
  • sample-tests are a set of bogus tests that the commands are run against to generate output
  • Coverage cannot be generated since phpunit is not executing the contents of src/ directly

Ironic.