fix: handle null Messages in TestRunAccumulator.Aggregate#3513
Open
jundayin wants to merge 4 commits intostryker-mutator:masterfrom
Open
fix: handle null Messages in TestRunAccumulator.Aggregate#3513jundayin wants to merge 4 commits intostryker-mutator:masterfrom
jundayin wants to merge 4 commits intostryker-mutator:masterfrom
Conversation
526f2b8 to
da987d0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the Microsoft Testing Platform runner crash described in #3510 by making TestRunAccumulator.Aggregate resilient when TestRunResult.Messages is null (which can occur for internally-failed test runs constructed via the simplified TestRunResult(false, ...) constructor).
Changes:
- Add a null-coalescing fallback when aggregating
TestRunResult.Messagesto preventArgumentNullException.
src/Stryker.TestRunner.MicrosoftTestPlatform/SingleMicrosoftTestPlatformRunner.cs
Show resolved
Hide resolved
src/Stryker.TestRunner.MicrosoftTestPlatform/SingleMicrosoftTestPlatformRunner.cs
Show resolved
Hide resolved
…tator#3510) When TestRunResult is created via the simple constructor (e.g. on internal test run failure), the Messages property is never initialized, causing ArgumentNullException in AddRange. Use null-coalescing fallback to empty collection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…utator#3510) Verify that TestRunResult.Messages is handled gracefully when null, covering the Aggregate path that previously threw ArgumentNullException. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…-mutator#3510) The root cause of the ArgumentNullException is that the simple constructor never initialized Messages, leaving it null. Fix it at the source by initializing to an empty collection. Keep the ?? [] fallback in Aggregate as defense in depth. Add regression tests to verify Messages is never null from either constructor path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e55b63f to
4692b67
Compare
src/Stryker.TestRunner.MicrosoftTestPlatform.UnitTest/SingleMicrosoftTestPlatformRunnerTests.cs
Show resolved
Hide resolved
src/Stryker.TestRunner.MicrosoftTestPlatform.UnitTest/SingleMicrosoftTestPlatformRunnerTests.cs
Outdated
Show resolved
Hide resolved
src/Stryker.TestRunner.MicrosoftTestPlatform.UnitTest/SingleMicrosoftTestPlatformRunnerTests.cs
Outdated
Show resolved
Hide resolved
…crosoftTestPlatformRunnerTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/Stryker.TestRunner.MicrosoftTestPlatform.UnitTest/SingleMicrosoftTestPlatformRunnerTests.cs
Show resolved
Hide resolved
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.
Summary
Messages = []in theTestRunResult(bool, string)simple constructor, which previously leftMessagesasnulldespite being typed as non-nullableIEnumerable<string>?? []) inTestRunAccumulator.AggregateTestRunResultTestsverifyingMessagesis never null from either constructor path, plusMessages.ShouldNotBeNull()assertions on existing integration testsTest plan
dotnet strykeragainst a project that previously triggered theArgumentNullException— exception no longer occursStryker.TestRunner.MicrosoftTestPlatform.UnitTest🤖 Generated with Claude Code