Skip to content

Commit 26d2f56

Browse files
Do not mark test that unintentionally covered code as risky when it fails
1 parent 4a02953 commit 26d2f56

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Framework/TestResult.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -849,13 +849,9 @@ function_exists('xdebug_start_function_monitor');
849849
$linesToBeUsed
850850
);
851851
} catch (UnintentionallyCoveredCodeException $cce) {
852-
$this->addFailure(
853-
$test,
854-
new UnintentionallyCoveredCodeError(
855-
'This test executed code that is not listed as code to be covered or used:' .
856-
PHP_EOL . $cce->getMessage()
857-
),
858-
$time
852+
$unintentionallyCoveredCodeError = new UnintentionallyCoveredCodeError(
853+
'This test executed code that is not listed as code to be covered or used:' .
854+
PHP_EOL . $cce->getMessage()
859855
);
860856
} catch (OriginalCodeCoverageException $cce) {
861857
$error = true;
@@ -876,6 +872,12 @@ function_exists('xdebug_start_function_monitor');
876872
$this->addFailure($test, $e, $time);
877873
} elseif ($warning) {
878874
$this->addWarning($test, $e, $time);
875+
} elseif (isset($unintentionallyCoveredCodeError)) {
876+
$this->addFailure(
877+
$test,
878+
$unintentionallyCoveredCodeError,
879+
$time
880+
);
879881
} elseif ($this->beStrictAboutTestsThatDoNotTestAnything &&
880882
!$test->doesNotPerformAssertions() &&
881883
$test->getNumAssertions() === 0) {

0 commit comments

Comments
 (0)