Skip to content

fix: handle null Messages in TestRunAccumulator.Aggregate#3513

Open
jundayin wants to merge 4 commits intostryker-mutator:masterfrom
jundayin:fix/3510-null-messages-in-aggregate
Open

fix: handle null Messages in TestRunAccumulator.Aggregate#3513
jundayin wants to merge 4 commits intostryker-mutator:masterfrom
jundayin:fix/3510-null-messages-in-aggregate

Conversation

@jundayin
Copy link
Copy Markdown

@jundayin jundayin commented Mar 31, 2026

Summary

  • Fixes ArgumentNullException in TestRunAccumulator.Aggregate when test run fails internally #3510
  • Root cause fix: Initializes Messages = [] in the TestRunResult(bool, string) simple constructor, which previously left Messages as null despite being typed as non-nullable IEnumerable<string>
  • Defense in depth: Keeps null-coalescing fallback (?? []) in TestRunAccumulator.Aggregate
  • Regression tests: Adds TestRunResultTests verifying Messages is never null from either constructor path, plus Messages.ShouldNotBeNull() assertions on existing integration tests

Test plan

  • Built locally and ran dotnet stryker against a project that previously triggered the ArgumentNullException — exception no longer occurs
  • All 144 unit tests pass in Stryker.TestRunner.MicrosoftTestPlatform.UnitTest

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 31, 2026 22:08
@jundayin jundayin force-pushed the fix/3510-null-messages-in-aggregate branch from 526f2b8 to da987d0 Compare March 31, 2026 22:10
Copy link
Copy Markdown
Contributor

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

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.Messages to prevent ArgumentNullException.

jundayin and others added 3 commits March 31, 2026 19:43
…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>
Copilot AI review requested due to automatic review settings April 1, 2026 02:43
@jundayin jundayin force-pushed the fix/3510-null-messages-in-aggregate branch from e55b63f to 4692b67 Compare April 1, 2026 02:43
Copy link
Copy Markdown
Contributor

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

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

…crosoftTestPlatformRunnerTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 1, 2026 07:58
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

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.

ArgumentNullException in TestRunAccumulator.Aggregate when test run fails internally

2 participants