diff --git a/src/WrapperRunner/ApplicationForWrapperWorker.php b/src/WrapperRunner/ApplicationForWrapperWorker.php index 5923ff84..1dc31543 100644 --- a/src/WrapperRunner/ApplicationForWrapperWorker.php +++ b/src/WrapperRunner/ApplicationForWrapperWorker.php @@ -11,6 +11,7 @@ use PHPUnit\Logging\JUnit\JunitXmlLogger; use PHPUnit\Logging\TeamCity\TeamCityLogger; use PHPUnit\Logging\TestDox\TestResultCollector; +use PHPUnit\Metadata\Api\CodeCoverage as CodeCoverageMetadataApi; use PHPUnit\Runner\CodeCoverage; use PHPUnit\Runner\Extension\ExtensionBootstrapper; use PHPUnit\Runner\Extension\Facade as ExtensionFacade; @@ -65,6 +66,12 @@ public function runTest(string $testPath): int (new TestSuiteFilterProcessor())->process($this->configuration, $testSuite); + if (CodeCoverage::instance()->isActive()) { + CodeCoverage::instance()->ignoreLines( + (new CodeCoverageMetadataApi())->linesToBeIgnored($testSuite), + ); + } + EventFacade::emitter()->testRunnerExecutionStarted( TestSuiteBuilder::from($testSuite), ); diff --git a/test/Unit/WrapperRunner/WrapperRunnerTest.php b/test/Unit/WrapperRunner/WrapperRunnerTest.php index 2edd9482..a870137a 100644 --- a/test/Unit/WrapperRunner/WrapperRunnerTest.php +++ b/test/Unit/WrapperRunner/WrapperRunnerTest.php @@ -496,6 +496,25 @@ public function testHandleCollisionWithSymfonyOutput(): void self::assertStringContainsString('', $runnerResult->output); } + /** @group github */ + #[CoversNothing] + public function testIgnoreAttributes(): void + { + $this->bareOptions['--configuration'] = $this->fixture('github' . DIRECTORY_SEPARATOR . 'GH756' . DIRECTORY_SEPARATOR . 'phpunit.xml'); + $this->bareOptions['--processes'] = '1'; + $runnerResult = $this->runRunner(); + + $expectedContains = <<<'EOF' + ParaTest\Tests\fixtures\github\GH756\CoveredOneClass + Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 1/ 1) + ParaTest\Tests\fixtures\github\GH756\CoveredTwoClass + Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 1/ 1) + EOF; + + self::assertEquals(0, $runnerResult->exitCode); + self::assertStringContainsString($expectedContains, $runnerResult->output); + } + public function testProcessIsolation(): void { $this->bareOptions['path'] = $this->fixture('process_isolation' . DIRECTORY_SEPARATOR . 'FooTest.php'); diff --git a/test/fixtures/github/GH756/CoveredOneClass.php b/test/fixtures/github/GH756/CoveredOneClass.php new file mode 100644 index 00000000..9060a9fb --- /dev/null +++ b/test/fixtures/github/GH756/CoveredOneClass.php @@ -0,0 +1,18 @@ +n(); + } + + private function n(): bool + { + return true; + } +} diff --git a/test/fixtures/github/GH756/CoveredOneTest.php b/test/fixtures/github/GH756/CoveredOneTest.php new file mode 100644 index 00000000..8ff71471 --- /dev/null +++ b/test/fixtures/github/GH756/CoveredOneTest.php @@ -0,0 +1,18 @@ +assertTrue((new CoveredOneClass())->m()); + } +} diff --git a/test/fixtures/github/GH756/CoveredTwoClass.php b/test/fixtures/github/GH756/CoveredTwoClass.php new file mode 100644 index 00000000..830ad536 --- /dev/null +++ b/test/fixtures/github/GH756/CoveredTwoClass.php @@ -0,0 +1,18 @@ +n(); + } + + private function n(): bool + { + return true; + } +} diff --git a/test/fixtures/github/GH756/CoveredTwoTest.php b/test/fixtures/github/GH756/CoveredTwoTest.php new file mode 100644 index 00000000..e263aedc --- /dev/null +++ b/test/fixtures/github/GH756/CoveredTwoTest.php @@ -0,0 +1,18 @@ +assertTrue((new CoveredTwoClass())->m()); + } +} diff --git a/test/fixtures/github/GH756/phpunit.xml b/test/fixtures/github/GH756/phpunit.xml new file mode 100644 index 00000000..2f1828b6 --- /dev/null +++ b/test/fixtures/github/GH756/phpunit.xml @@ -0,0 +1,19 @@ + + + + CoveredOneClass.php + CoveredTwoClass.php + + + + + + + + + + CoveredOneTest.php + CoveredTwoTest.php + + + diff --git a/test/fixtures/github/GH756/tmp/.gitignore b/test/fixtures/github/GH756/tmp/.gitignore new file mode 100644 index 00000000..c96a04f0 --- /dev/null +++ b/test/fixtures/github/GH756/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file