Skip to content

Commit e78ff70

Browse files
Do not emit "Before Test Method Errored" event when a test is skipped in a "before test" method
1 parent 239ad55 commit e78ff70

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

ChangeLog-11.5.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi
1010
* The peak memory usage returned by `memory_get_peak_usage()` is now reset immediately before the `Test\Prepared` event is emitted using `memory_reset_peak_usage()` so that (memory usage at `Test\Finished` - memory usage at `Test\Prepared`) is a better approximation of the memory usage of the test
1111
* The string representation of `Telemetry\Info` now uses peak memory usage instead of memory usage (this affects `--log-events-verbose-text`)
1212

13+
### Fixed
14+
15+
* A "Before Test Method Errored" event is no longer emitted when a test is skipped in a "before test" method
16+
1317
## [11.5.17] - 2025-04-08
1418

1519
### Fixed

src/Framework/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,7 @@ private function invokeHookMethods(HookMethodCollection $hookMethods, Event\Emit
24452445

24462446
$methodsInvoked[] = $methodInvoked;
24472447

2448-
if (isset($t)) {
2448+
if (isset($t) && !$t instanceof SkippedTest) {
24492449
$emitter->{$erroredMethod}(
24502450
static::class,
24512451
$methodInvoked,

tests/end-to-end/event/test-skipped-in-setup.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Test Runner Execution Started (1 test)
2121
Test Suite Started (PHPUnit\TestFixture\Event\SkippedInSetupTest, 1 test)
2222
Test Preparation Started (PHPUnit\TestFixture\Event\SkippedInSetupTest::testOne)
2323
Before Test Method Called (PHPUnit\TestFixture\Event\SkippedInSetupTest::setUp)
24-
Before Test Method Errored (PHPUnit\TestFixture\Event\SkippedInSetupTest::setUp)
2524
Before Test Method Finished:
2625
- PHPUnit\TestFixture\Event\SkippedInSetupTest::setUp
2726
Test Skipped (PHPUnit\TestFixture\Event\SkippedInSetupTest::testOne)

0 commit comments

Comments
 (0)