Skip to content

Commit bee8dfe

Browse files
1 parent ebe95d0 commit bee8dfe

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/cli-options.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ Execution
134134
``--strict-coverage``
135135
Enforces strict mode for code coverage metadata. Tests that execute code not declared in their ``#[Covers*]`` or ``#[Uses*]`` metadata will be marked as risky.
136136

137+
``--require-coverage-contribution``
138+
Marks tests as risky when they have code coverage targets but do not execute any line of the targeted code.
139+
137140
``--strict-global-state``
138141
Enforces strict checking of global state changes. Tests that modify global state (such as global variables, super-globals, or static properties) will be marked as risky.
139142

src/configuration.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ Possible values: ``true`` or ``false`` (default: ``false``)
356356

357357
This attribute configures whether PHPUnit should mark a test as risky when it executes code that is not specified to be covered or used using an attribute.
358358

359+
.. _appendixes.configuration.phpunit.requireCoverageContribution:
360+
361+
The ``requireCoverageContribution`` Attribute
362+
---------------------------------------------
363+
364+
Possible values: ``true`` or ``false`` (default: ``false``)
365+
366+
This attribute configures whether PHPUnit should mark a test as risky when it has code coverage targets but does not execute any line of the targeted code.
367+
359368
.. _appendixes.configuration.phpunit.enforceTimeLimit:
360369

361370
The ``enforceTimeLimit`` Attribute

src/risky-tests.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ metadata (such as ``CoversClass``, ``CoversMethod``, ``CoversFunction``, ``Cover
5858
Unlike the strict coverage check described above, this check is performed regardless of the test's size (``#[Small]``, ``#[Medium]``, or ``#[Large]``).
5959

6060

61+
.. _risky-tests.no-code-coverage-contribution:
62+
63+
No Code Coverage Contribution
64+
=============================
65+
66+
PHPUnit can be strict about tests that do not contribute to code coverage. This check
67+
can be enabled by using the ``--require-coverage-contribution`` option on
68+
the :ref:`command-line <appendixes.cli-options.execution>` or by setting
69+
``requireCoverageContribution="true"`` in PHPUnit's
70+
:ref:`XML configuration file <appendixes.configuration>`.
71+
72+
A test that has :ref:`code coverage targets <code-coverage.targeting-units-of-code>` but does not execute any line of the targeted code will be considered risky when this check is enabled.
73+
74+
6175
.. _risky-tests.output-during-test-execution:
6276

6377
Output During Test Execution

0 commit comments

Comments
 (0)