Skip to content

Commit 4f31ea0

Browse files
Implement --only-summary-for-coverage-text and --show-uncovered-for-coverage-text CLI options
1 parent e3d9a1b commit 4f31ea0

File tree

6 files changed

+288
-255
lines changed

6 files changed

+288
-255
lines changed

ChangeLog-11.1.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes of the PHPUnit 11.1 release series are documented in this fi
88

99
* [#5175](https://github.com/sebastianbergmann/phpunit/issues/5175): `#[CoversMethod]` and `#[UsesMethod]` attributes for more fine-grained code coverage targeting
1010
* [#5696](https://github.com/sebastianbergmann/phpunit/pull/5696): `#[DisableReturnValueGenerationForTestDoubles]` attribute for disabling return value generation for test doubles created using `createMock()`, `createMockForIntersectionOfInterfaces()`, `createPartialMock()`, `createStub()`, and `createStubForIntersectionOfInterfaces()`
11+
* `--only-summary-for-coverage-text` CLI option to reduce the code coverage report in text format to a summary
12+
* `--show-uncovered-for-coverage-text` CLI option to expand the code coverage report in text format to include a list of uncovered files
1113

1214
### Changed
1315

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ final class Builder
4747
'coverage-html=',
4848
'coverage-php=',
4949
'coverage-text==',
50+
'only-summary-for-coverage-text',
51+
'show-uncovered-for-coverage-text',
5052
'coverage-xml=',
5153
'path-coverage',
5254
'disallow-test-output',
@@ -331,9 +333,17 @@ public function fromParameters(array $parameters): Configuration
331333
$option[1] = 'php://stdout';
332334
}
333335

334-
$coverageText = $option[1];
335-
$coverageTextShowUncoveredFiles = false;
336-
$coverageTextShowOnlySummary = false;
336+
$coverageText = $option[1];
337+
338+
break;
339+
340+
case '--only-summary-for-coverage-text':
341+
$coverageTextShowOnlySummary = true;
342+
343+
break;
344+
345+
case '--show-uncovered-for-coverage-text':
346+
$coverageTextShowUncoveredFiles = true;
337347

338348
break;
339349

src/TextUI/Configuration/Merger.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
333333
$coverageTextShowOnlySummary = $xmlConfiguration->codeCoverage()->text()->showOnlySummary();
334334
}
335335

336+
if ($cliConfiguration->hasCoverageTextShowUncoveredFiles()) {
337+
$coverageTextShowUncoveredFiles = $cliConfiguration->coverageTextShowUncoveredFiles();
338+
}
339+
340+
if ($cliConfiguration->hasCoverageTextShowOnlySummary()) {
341+
$coverageTextShowOnlySummary = $cliConfiguration->coverageTextShowOnlySummary();
342+
}
343+
336344
if ($cliConfiguration->hasCoverageText()) {
337345
$coverageText = $cliConfiguration->coverageText();
338346
} elseif ($coverageFromXmlConfiguration && $xmlConfiguration->codeCoverage()->hasText()) {

src/TextUI/Help.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ private function elements(): array
270270
['arg' => '--coverage-html <dir>', 'desc' => 'Write code coverage report in HTML format to directory'],
271271
['arg' => '--coverage-php <file>', 'desc' => 'Write serialized code coverage data to file'],
272272
['arg' => '--coverage-text=<file>', 'desc' => 'Write code coverage report in text format to file [default: standard output]'],
273+
['arg' => '--only-summary-for-coverage-text', 'desc' => 'Option for code coverage report in text format: only show summary'],
274+
['arg' => '--show-uncovered-for-coverage-text', 'desc' => 'Option for code coverage report in text format: show uncovered files'],
273275
['arg' => '--coverage-xml <dir>', 'desc' => 'Write code coverage report in XML format to directory'],
274276
['arg' => '--warm-coverage-cache', 'desc' => 'Warm static analysis cache'],
275277
['arg' => '--coverage-filter <dir>', 'desc' => 'Include <dir> in code coverage reporting'],

0 commit comments

Comments
 (0)