fix: preserve TRX results when session cleanup fails - #6879
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe engine reports flattened exception details in synthetic TRX error nodes while preserving the original exception for console clients. Added test cases and engine tests cover passing results, test-body failures, and shared-resource disposal errors. ChangesUnhandled exception TRX reporting
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No specific issue is established that should prevent merging after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks the TRX report, Comment |
|
ReviewThis PR fixes a real bug: when
Suggestion: extract the shared TRX-folding logic
var folded = FlattenedException.Wrap(exception);
propertyBag.Add(new TrxExceptionProperty(
folded.Message,
string.IsNullOrEmpty(folded.StackTrace) ? null : folded.StackTrace));Both call sites now independently implement "fold the exception, then build a This is a maintainability nit, not a correctness issue — the current code is correct and safe to merge as-is. |
|
Thanks @Sing303 ! |
Updated [TUnit](https://github.com/thomhurst/TUnit) from 1.69.0 to 1.69.16. <details> <summary>Release notes</summary> _Sourced from [TUnit's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.69.16 <!-- Release notes generated using configuration in .github/release.yml at v1.69.16 --> ## What's Changed ### Other Changes * fix: preserve TRX results when session cleanup fails by @Sing303 in thomhurst/TUnit#6879 ### Dependencies * chore(deps): update tunit to 1.69.0 by @thomhurst in thomhurst/TUnit#6864 * chore(deps): update dependency messagepack to 3.1.10 by @thomhurst in thomhurst/TUnit#6866 * chore(deps): update dependency dompurify to v3.4.16 by @thomhurst in thomhurst/TUnit#6867 * chore(deps): update dependency serialize-javascript to v7.1.2 by @thomhurst in thomhurst/TUnit#6868 * chore(deps): update dependency azure.data.tables to 12.13.0 by @thomhurst in thomhurst/TUnit#6870 * chore(deps): update dependency microsoft.playwright to 1.63.0 by @thomhurst in thomhurst/TUnit#6871 * chore(deps): update verify to 33.1.2 by @thomhurst in thomhurst/TUnit#6872 * chore(deps): update dependency verify.tool to v0.9.2 by @thomhurst in thomhurst/TUnit#6873 * chore(deps): update verify to 33.1.3 by @thomhurst in thomhurst/TUnit#6874 * chore(deps): update verify to 33.1.4 by @thomhurst in thomhurst/TUnit#6876 * chore(deps): update dependency moq to 4.21.0 by @thomhurst in thomhurst/TUnit#6877 * chore(deps): bump image-size from 2.0.2 to 2.0.4 in /docs by @dependabot[bot] in thomhurst/TUnit#6878 ## New Contributors * @Sing303 made their first contribution in thomhurst/TUnit#6879 **Full Changelog**: thomhurst/TUnit@v1.69.0...v1.69.16 Commits viewable in [compare view](thomhurst/TUnit@v1.69.0...v1.69.16). </details> Updated [TUnit.AspNetCore](https://github.com/thomhurst/TUnit) from 1.69.0 to 1.69.16. <details> <summary>Release notes</summary> _Sourced from [TUnit.AspNetCore's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.69.16 <!-- Release notes generated using configuration in .github/release.yml at v1.69.16 --> ## What's Changed ### Other Changes * fix: preserve TRX results when session cleanup fails by @Sing303 in thomhurst/TUnit#6879 ### Dependencies * chore(deps): update tunit to 1.69.0 by @thomhurst in thomhurst/TUnit#6864 * chore(deps): update dependency messagepack to 3.1.10 by @thomhurst in thomhurst/TUnit#6866 * chore(deps): update dependency dompurify to v3.4.16 by @thomhurst in thomhurst/TUnit#6867 * chore(deps): update dependency serialize-javascript to v7.1.2 by @thomhurst in thomhurst/TUnit#6868 * chore(deps): update dependency azure.data.tables to 12.13.0 by @thomhurst in thomhurst/TUnit#6870 * chore(deps): update dependency microsoft.playwright to 1.63.0 by @thomhurst in thomhurst/TUnit#6871 * chore(deps): update verify to 33.1.2 by @thomhurst in thomhurst/TUnit#6872 * chore(deps): update dependency verify.tool to v0.9.2 by @thomhurst in thomhurst/TUnit#6873 * chore(deps): update verify to 33.1.3 by @thomhurst in thomhurst/TUnit#6874 * chore(deps): update verify to 33.1.4 by @thomhurst in thomhurst/TUnit#6876 * chore(deps): update dependency moq to 4.21.0 by @thomhurst in thomhurst/TUnit#6877 * chore(deps): bump image-size from 2.0.2 to 2.0.4 in /docs by @dependabot[bot] in thomhurst/TUnit#6878 ## New Contributors * @Sing303 made their first contribution in thomhurst/TUnit#6879 **Full Changelog**: thomhurst/TUnit@v1.69.0...v1.69.16 Commits viewable in [compare view](thomhurst/TUnit@v1.69.0...v1.69.16). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description
When a session-level failure reaches
TUnitTestFramework.ReportUnhandledException, TUnit publishes a synthetic error node with onlyErrorTestNodeStateProperty. With--report-trx, Microsoft.Testing.Platform 2.4.1 cannot determine a class name for that node and throws while generating the report:This can discard the results of tests that already completed. The regression in this PR runs one passing test and one failing test, followed by a static
ClassDataSourceresource whoseDisposeAsyncthrows. On the unmodifiedmainata1fa4a2, the generated TRX has 0 results, and the regression fails expecting 3.The synthetic node now carries:
TrxFullyQualifiedTypeNameProperty, identifying the framework because there is no user test method for a session-level failure.TrxExceptionProperty, using the existingFlattenedExceptionhandling so both the cleanup exception and its inner causes retain their messages and stack traces in TRX.The report then contains 3 results: 1 passed and 2 failed (the original test failure and the session cleanup failure). The test process still exits with code 10 for the failed session. Exception propagation, cleanup behavior, and the console/IDE state-property distinction are unchanged.
The reproducer requires both a test to use the resource and the child-process-only
TUNIT_TEST_THROW_ON_STATIC_RESOURCE_DISPOSAL=1opt-in. Static data sources can be initialized even when their tests are filtered out; selectingPassingTestdirectly or including this fixture in another run does not activate the cleanup failure. A second regression explicitly removes the opt-in from its child process and verifies that the passing test completes the session successfully.Related Issue
No separate issue. This PR includes the reproduction and regression test. It complements #6777: that change preserves nested exceptions, but synthetic unhandled-error nodes still lack the TRX metadata supplied for ordinary test results.
Type of Change
Checklist
mainbefore applying the fix.Testing
Windows x64, .NET SDK 10.0.401, Microsoft.Testing.Platform / TRX 2.4.1.
Built the child test application, as required by
InvokableTestBase:Ran the new regression and existing nested-exception TRX regressions:
Result: 5 passed, 0 failed, 5 AOT rows skipped by the existing local-run policy. This includes the existing nested and aggregate exception tests from #6777 and the opt-in isolation regression, which failed before the isolation fix (expected a completed session, got a failed session).
Also ran the reproducer directly in source-generated mode:
The deliberately failing process exits with code 10. Parsed the resulting TRX and verified all three outcomes, the original test-failure message and stack, and the cleanup-failure message and stack.
Also ran only
PassingTestdirectly in source-generated mode without the opt-in: exit code 0, one passed result, no session cleanup failure.The full repository suite and Native AOT publish were not run locally.
Summary by CodeRabbit