Fix "Test host process crashed" when a theory data member throws#649
Merged
delatrie merged 1 commit intoallure-framework:mainfrom Apr 24, 2026
Merged
Conversation
…n failure and success wip test & local build update Microsoft.CodeAnalysis.CSharp package to version 5.0.0
There was a problem hiding this comment.
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/OnTestPassedstart an Allure test case on-demand when no test context is active, mirroring the existing defensive handling inOnTestSkipped. - Add a new integration test asserting that a theory with a throwing
MemberDatasource is recorded asbroken. - Add a new xUnit sample that triggers a
MemberDataexception 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.
delatrie
approved these changes
Apr 24, 2026
Contributor
delatrie
left a comment
There was a problem hiding this comment.
Thank you for your contribution.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
OnTestFailedandOnTestPassedinAllureMessageSink.csto useUpdateTestContextand ensure that Allure test cases are started if not already present, improving reliability in test case lifecycle management. [1] [2]OnTestSkippedalready handles this case defensively. OnTestFailed and OnTestPassed don't. The fix is to apply the same pattern.Support and testing for broken data sources:
TheoryWithThrowingMemberDataIsRecordedAsBrokeninBrokenDataSourceTests.csto verify that theories with member data sources that throw exceptions are marked as "broken" in the test results.TheoryWithThrowingMemberDatawhere the data source method intentionally throws an exception, to support the new test scenario.Checklist