phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Option to mark test as risky when it does not generate code coverage

Open sebastianbergmann opened this issue 4 years ago • 2 comments

Suggested by @spriebsch:

When code coverage analysis is active then a test that is not annotated with @coversNothing and does not contribute to code coverage should be marked as risky.

Motivation: We frequently see "tests" like this:

<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class ExampleTest extends TestCase
{
    public function testSomething(): void
    {
        $this->assertTrue(true);
    }
}

This is done in order to prevent the test from being marked as risky because it does not assert anything and/or to create the false impression that a project has tests.

sebastianbergmann avatar Oct 30 '20 08:10 sebastianbergmann

Thanks for being my GitHub proxy, again ;-)

spriebsch avatar Oct 30 '20 09:10 spriebsch

Hi @sebastianbergmann and @spriebsch, I think this is a nice idea! I would love to help and made a quick prove of concept. Is this the place and way you thought of, or would you tackle this completely different? https://github.com/sebastianbergmann/phpunit/compare/master...R4c00n:risky-because-no-coverage?expand=1

As I said, this is just a quick POC. Still missing proper tests and configuration options and stuff.

R4c00n avatar Nov 02 '20 20:11 R4c00n