Skip to content

fix(lifecycle): keep the test failure when a lifecycle hook throws - #378

Open
roxblnfk wants to merge 1 commit into
1.xfrom
fix/lifecycle-hook-failures
Open

roxblnfk wants to merge 1 commit into
1.xfrom
fix/lifecycle-hook-failures

Conversation

@roxblnfk

Copy link
Copy Markdown
Member

🔍 What was changed

  • A throwing #[BeforeTest] stops the remaining setup hooks and the test body. The test is Error with that exception, not Aborted.
  • #[AfterTest] hooks always run: after a failed setup too, and each one even when a previous one threw.
  • A throwing teardown turns a passed test into Error. A failed test keeps its own failure.
  • Hook exceptions that do not become the test's failure go to the test's stderr channel.

Why?

A failing #[AfterTest] replaced the test result with a PipelineFailure, so a red test showed only the teardown error and its real failure was lost.

Checklist

  • How was this tested:
    • Feature tests added
    • Full suite run locally without benches

Documentation

  • testo-write-tests skill describes how hook failures are reported.

docs(skills): describe how lifecycle hook failures are reported

A throwing #[AfterTest] replaced the test result with an Aborted pipeline failure, so the test's own failure disappeared from the report, and a throwing #[BeforeTest] skipped every #[AfterTest]. Hook failures are now test errors, teardown always runs, and throwables that do not become the test's failure go to the stderr channel.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk requested a review from a team as a code owner September 30, 2026 18:37
@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...in/lifecycle/src/Internal/LifecycleInterceptor.php 91.66% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant