Skip to content

Fix "Test host process crashed" when a theory data member throws#649

Merged
delatrie merged 1 commit intoallure-framework:mainfrom
iampopovich:fix/attempt-to-handle-context-missing
Apr 24, 2026
Merged

Fix "Test host process crashed" when a theory data member throws#649
delatrie merged 1 commit intoallure-framework:mainfrom
iampopovich:fix/attempt-to-handle-context-missing

Conversation

@iampopovich
Copy link
Copy Markdown
Contributor

Context

hope it solves #528 , assisted by QWEN code

This pull request improves the handling and reporting of test cases in scenarios where test data sources throw exceptions, ensuring that such cases are properly recorded as "broken" in the Allure test results. It also refactors the test context management logic for test pass and fail events to ensure Allure test cases are started correctly when needed.

Enhancements to test result handling:

  • Refactored the logic in OnTestFailed and OnTestPassed in AllureMessageSink.cs to use UpdateTestContext and ensure that Allure test cases are started if not already present, improving reliability in test case lifecycle management. [1] [2]
    OnTestSkipped already handles this case defensively. OnTestFailed and OnTestPassed don't. The fix is to apply the same pattern.

Support and testing for broken data sources:

  • Added a new test TheoryWithThrowingMemberDataIsRecordedAsBroken in BrokenDataSourceTests.cs to verify that theories with member data sources that throw exceptions are marked as "broken" in the test results.
  • Introduced a sample test class TheoryWithThrowingMemberData where the data source method intentionally throws an exception, to support the new test scenario.

Checklist

…n failure and success

wip test & local build

update Microsoft.CodeAnalysis.CSharp package to version 5.0.0
Copilot AI review requested due to automatic review settings April 17, 2026 21:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Allure xUnit adapter resilience when xUnit reports failures/passes without an active Allure test context (notably when theory data sources throw), ensuring results are still recorded instead of crashing the test host process.

Changes:

  • Make OnTestFailed / OnTestPassed start an Allure test case on-demand when no test context is active, mirroring the existing defensive handling in OnTestSkipped.
  • Add a new integration test asserting that a theory with a throwing MemberData source is recorded as broken.
  • Add a new xUnit sample that triggers a MemberData exception for the new test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Allure.Xunit/AllureMessageSink.cs Ensures a test case is started before applying pass/fail updates when Allure context is missing.
tests/Allure.Xunit.Tests/BrokenDataSourceTests.cs Adds coverage to verify throwing data sources are reported as broken.
tests/Allure.Xunit.Tests/Samples/TheoryWithThrowingMemberData.cs Introduces a sample theory whose MemberData provider throws to reproduce the scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Allure.Xunit/AllureMessageSink.cs
Copy link
Copy Markdown
Contributor

@delatrie delatrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

@delatrie delatrie changed the title Fix/attempt to handle context missing Fix "Test host process crashed" when a theory data member throws Apr 24, 2026
@delatrie delatrie added the type:bug Something isn't working label Apr 24, 2026
@delatrie delatrie merged commit dc8675a into allure-framework:main Apr 24, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:xunit type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants