Skip to content

JeroenDeDauw/covers-validator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ockcyp/covers-validator

Build Status Coverage Status Scrutinizer Code Quality License

PHPUnit @covers tags validator

PHPUnit fails to generate coverage report when tests have invalid @covers tags.

This tool allows you to determine the tests that have invalid @covers tags without you needing to run the coverage.

Usually coverage reports are run less often than the tests as it takes a long time to run. This tool validates your @covers tags quicker than you run your tests.

Also see: dunkelfrosch/phpcoverfish

Why?

Trying to @cover or @use not existing class or interface "NonExistentClass".
Trying to @cover or @use not existing method "ExistingClass::nonExistantMethod".

See: phpunit/issues/1758
Also see: phpunit/issues/1791

Installation

composer require --dev ockcyp/covers-validator

Usage

vendor/bin/covers-validator

Give optional -c argument to load a particular PHPUnit configuration file:

vendor/bin/covers-validator -c tests/Fixtures/configuration.xml

Override bootstrap specified in PHPUnit configuration:

vendor/bin/covers-validator --bootstrap tests/bootstrap.php

Disable output by providing -q argument

vendor/bin/covers-validator -q

Adjust the verbosity:

Verbosity Shows
-v Valid tests
-vv Loaded configuration file
-vvv Test name before validation is done

Sample output

Normal verbosity

Invalid - OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringNonExistentClassTest::testDummyTest

There were 1 test(s) with invalid @covers tags.

Maximum verbosity (debug)

Configuration file loaded: /home/omer/Projects/Personal/covers-validator/tests/Fixtures/configuration-all.xml

Validating OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringExistingClassTest::testDummyTest...
Valid - OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringExistingClassTest::testDummyTest
Validating OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringNonExistentClassTest::testDummyTest...
Invalid - OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringNonExistentClassTest::testDummyTest

There were 1 test(s) with invalid @covers tags.

Tip: Command gives exit code 1 when any of the covers tags are invalid. Use this to fail your builds.

Tests

To run the tests, execute:

vendor/bin/phpunit

About

Validates @Covers tags in PHPUnit tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%