oradwell / covers-validator Goto Github PK
View Code? Open in Web Editor NEWValidates covers tags in PHPUnit tests
License: MIT License
Validates covers tags in PHPUnit tests
License: MIT License
ockcyp/covers-validator v0.5.0 requires phpunit/phpunit ^4.0.0 || ^5.0
For tests with data providers PHPUnit's PHPUnit\Util\Test::getLinesToBeCovered
does not throw PHPUnit\Framework\CoverageException
. Need to find an alternative way of getting it working.
Hi, nice tool thanks for it.
Would it be possible to get a phar instead of a composer dependency? Such tools are dedicated applications and you shouldn't have to add them to your project dependency (exactly as for phpunit and any static analysis tool).
Cheers
Hi, I have a phpunit.xml
with multiple test suites:
<testsuites>
<testsuite name="Unit tests">
<directory>../tests/unittests</directory>
</testsuite>
<testsuite name="Integration tests">
<directory>../tests/integration</directory>
</testsuite>
</testsuites>
This results in an exception:
[ReflectionException]
Class Unit tests does not exist
It works fine, if I comment the second test suite away. I could not find any obvious uses of the Reflection API in your project, so I am not sure where this is coming from.
PR #33 accidentally changed the name of the class from PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper
to PHPUnit\TextUI\XmlConfiguration\TestSuiteMappe
, breaking the program for PHPUnit 9.3 and PHPUnit 9.4
When a test method has an empty covers tag PHPUnit fails with Trying to @cover or @use not existing class or interface "".
but covers-validator does not fail.
/**
* @covers
*/
public function testSomethingWorks()
{
...
}
When upgrading to 1.2.0 with PHPUnit 9.3.7 I can no longer get covers-validator working:
PHP Fatal error: Uncaught Error: Class 'PHPUnit\TextUI\Configuration\Loader' not found in /Users/tfidry/Project/Alice/nelmio/vendor-bin/covers-validator/vendor/ockcyp/covers-validator/src/Loader/ConfigLoader.php:30
See https://travis-ci.org/github/nelmio/alice/jobs/720270946
Adding this as a dependency causes all this stuff to be pulled in:
That triples the packages being pulled in for a lot of my projects. Can this not be avoided?
Thanks for creating this, much appreciated :)
Often in standard PHP configurations the memory_limit value is set to 128M. From tests I've seen covers-validator needs more.
In my case 512M was enough, but it's perhaps worth to add more.
For example composer raises internally to 1.5GB.
I think something similar is a good addition to covers-validator.
/E: The quick fix for me is to set it from the outside:
$ php -dmemory_limit=512M -f "$(which covers-validator)"
I think not needing this on first hand would make use/integration easier. Thanks for this working tool, I tried the other one you linked and I could only report issues w/o getting it to run.
The composer.json
file requires "symfony/console": "^2.3 || ^3.0"
, but the command calls addUsage
method that has been introduced in version 2.7.
Hi @ockcyp.
I am getting an error, when the invalid @covers
annotation has a class and the annotation is to cover parent classes as wel:
* @covers Model_OAuth2_Application<extended>
This gives the following error if the class does not exist:
[exec] [ErrorException]
[exec] class_implements(): Class Model_OAuth2_Application does not exist and could not be loaded
[exec]
[exec]
[exec]
[exec] validate [-c|--configuration CONFIGURATION] [--bootstrap BOOTSTRAP]
Probably something internal in PHPUnit again?
Should I be using ~0.3.0
, or is it safe to do ~0.3
, in projects that only execute vendor/bin/covers-validator
with no further arguments?
Even though the CI here passes with PHPUNit 7.x, in my project I get an error when I use covers-validator with 7.x instead of 6.x:
CoversValidator 0.7.0
Fatal error: Uncaught Error: Class 'PHPUnit\Util\Fileloader' not found in /app/vendor/ockcyp/covers-validator/src/Loader/FileLoader.php:16
Stack trace:
#0 /app/vendor/ockcyp/covers-validator/src/Handler/InputHandler.php(31): OckCyp\CoversValidator\Loader\FileLoader::loadFile('/app/tests/boot...')
#1 /app/vendor/ockcyp/covers-validator/src/Command/ValidateCommand.php(52): OckCyp\CoversValidator\Handler\InputHandler::handleInput(Object(Symfony\Component\Console\Input\ArgvInput))
#2 /app/vendor/symfony/console/Command/Command.php(252): OckCyp\CoversValidator\Command\ValidateCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /app/vendor/symfony/console/Application.php(946): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OckCyp\CoversVal in /app/vendor/ockcyp/covers-validator/src/Loader/FileLoader.php on line 16
I saw your project on /r/php. Cool! We run into this issue every now and then and it would be great if we could have a fast check on the @covers
annotations.
I installed your package using composer and then tried to run it with our configuration file as follows:
./vendor/bin/covers-validator -c tests/phpunit.xml
.
However I does not seem to load the bootstrap file referenced the configuration XML file. Our autoloader is not included.
Our config file starts with:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
bootstrap="./bootstrap.php"
colors="true">
<php>
...
Of course, this results in a class not found error, because our test cases extend from our own class (which extends from PHPUnit_Framework_TestCase
).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.