Skip to content

Commit

Permalink
Specify test name when initing TestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 22, 2019
1 parent 41a5260 commit 24e7530
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
19 changes: 19 additions & 0 deletions tests/_files/CoverageClassWithoutAnnotationsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use PHPUnit\Framework\TestCase;

class CoverageClassWithoutAnnotationsTest extends TestCase
{
public function testSomething(): void
{
$o = new CoveredClass;
$o->publicMethod();
}
}
10 changes: 6 additions & 4 deletions tests/unit/Util/TestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1332,17 +1332,19 @@ public function testCanSkipCoverage($testCase, $expectedCanSkip): void
{
require_once TEST_FILES_PATH . $testCase . '.php';

$test = new $testCase;
$canSkipCoverage = Test::requiresCodeCoverageDataCollection($test);
$test = new $testCase('testSomething');
$coverageRequired = Test::requiresCodeCoverageDataCollection($test);
$canSkipCoverage = !$coverageRequired;

$this->assertEquals($expectedCanSkip, $canSkipCoverage);
}

public function canSkipCoverageProvider(): array
{
return [
['CoverageClassTest', true],
['CoverageNothingTest', true],
['CoverageClassWithoutAnnotationsTest', false],
['CoverageClassTest', false],
['CoverageNothingTest', false],
['CoverageCoversOverridesCoversNothingTest', false],
];
}
Expand Down

0 comments on commit 24e7530

Please sign in to comment.