Skip to content

Fix MSTEST0068 build errors: replace CollectionAssert with Assert.AreSequenceEqual#8815

Closed
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/fix-mstest0068-collectionassert
Closed

Fix MSTEST0068 build errors: replace CollectionAssert with Assert.AreSequenceEqual#8815
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/fix-mstest0068-collectionassert

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Builds were failing with 99 MSTEST0068 errors (e.g. on #8811) after the new CollectionAssertToAssertAnalyzer started reporting against existing call sites in our own unit tests.

This PR applies the analyzer's suggested fix at every flagged location:

  • CollectionAssert.AreEqual(a, b)Assert.AreSequenceEqual(a, b)
  • CollectionAssert.AreEquivalent(a, b)Assert.AreSequenceEqual(a, b, SequenceOrder.InAnyOrder)

I reviewed each of the 31 distinct call sites individually — all of them operate on simple string[] collections where the suggested mapping is semantically equivalent (default equality, ordered vs. multiset semantics preserved), so no analyzer suggestion needed to be opted out and no follow-up issue is required.

Files touched:

  • test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/JsonCommandLineOptionsTests.cs
  • test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/CommandLineConfigurationExtensionsTests.cs
  • test/UnitTests/Microsoft.Testing.Platform.UnitTests/Services/CurrentTestApplicationModuleInfoTests.cs
  • test/UnitTests/Microsoft.Testing.Extensions.UnitTests/AzureDevOpsArtifactUploaderTests.cs
  • test/UnitTests/Microsoft.Testing.Extensions.UnitTests/AzureDevOpsLivePublishingTests.cs
  • test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs
  • test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxStreamingSerializerTests.cs

Verified locally with:

build.cmd -c Debug -projects test\UnitTests\Microsoft.Testing.Platform.UnitTests\Microsoft.Testing.Platform.UnitTests.csproj
build.cmd -c Debug -projects test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj /warnaserror /p:TreatWarningsAsErrors=true

Both succeed with 0 errors / 0 warnings.

Replace CollectionAssert.AreEqual with Assert.AreSequenceEqual and
CollectionAssert.AreEquivalent with Assert.AreSequenceEqual(...,
SequenceOrder.InAnyOrder) in the affected unit-test files. All call sites
operate on string collections where the suggested mapping is semantically
equivalent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 4, 2026 08:07
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

This PR updates unit tests across Microsoft.Testing.Platform and Microsoft.Testing.Extensions to address MSTEST0068 by replacing CollectionAssert collection comparisons with the newer Assert.AreSequenceEqual APIs (including SequenceOrder.InAnyOrder where the previous intent was order-insensitive equivalence).

Changes:

  • Replaced CollectionAssert.AreEqual(...) with Assert.AreSequenceEqual(...) in several unit tests validating argument/option sequences.
  • Replaced CollectionAssert.AreEquivalent(...) with Assert.AreSequenceEqual(..., SequenceOrder.InAnyOrder) where ordering is not significant.
  • Standardized collection assertion usage to align with the CollectionAssertToAssertAnalyzer mapping and eliminate analyzer build breaks.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/JsonCommandLineOptionsTests.cs Swaps CollectionAssert.AreEqual for Assert.AreSequenceEqual when validating parsed option argument lists.
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/CommandLineConfigurationExtensionsTests.cs Uses Assert.AreSequenceEqual for command-line argument arrays returned from configuration helpers.
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Services/CurrentTestApplicationModuleInfoTests.cs Updates argument sequence assertions to Assert.AreSequenceEqual for executable argument construction scenarios.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/AzureDevOpsArtifactUploaderTests.cs Replaces AreEquivalent/AreEqual with AreSequenceEqual, using SequenceOrder.InAnyOrder for tag assertions.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/AzureDevOpsLivePublishingTests.cs Updates ordered event sequence assertion to Assert.AreSequenceEqual.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/CrashDumpTests.cs Updates dump-path sequence assertions to Assert.AreSequenceEqual.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxStreamingSerializerTests.cs Updates category sequence assertion to Assert.AreSequenceEqual.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 0

@Evangelink
Copy link
Copy Markdown
Member Author

Superseded: the fix was pushed directly to the Maestro branch on #8811 instead.

@Evangelink Evangelink closed this Jun 4, 2026
@Evangelink Evangelink deleted the dev/amauryleve/fix-mstest0068-collectionassert branch June 4, 2026 08:12
Copy link
Copy Markdown
Member Author

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

Code Review — PR #8815: Fix MSTEST0068 (Replace CollectionAssert with Assert.AreSequenceEqual)

Verdict: ✅ All 21 dimensions clean — no issues found.

Summary

This is a pure mechanical fix that applies the MSTEST0068 analyzer's suggested replacements at 31 call sites across 7 test files. No production code is touched.

Mapping applied Semantic equivalence
CollectionAssert.AreEqual(expected, actual)Assert.AreSequenceEqual(expected, actual) ✅ Ordered comparison preserved
CollectionAssert.AreEquivalent(expected, actual)Assert.AreSequenceEqual(expected, actual, SequenceOrder.InAnyOrder) ✅ Unordered / multiset semantics preserved

Parameter order (expected first, actual second) is consistent between the old and new APIs — confirmed against Assert.AreSequenceEqual.cs. No argument swaps introduced.

All changed call sites operate on string[] with default equality — no custom comparers were in play, so no information is lost in the migration. The two AreEquivalentInAnyOrder conversions correctly preserve the unordered semantics that were intended.

The PR description notes local verification with -warnaserror passing at 0 errors / 0 warnings — consistent with the change being a pure compliant migration.

No blocking or major issues across any of the 21 review dimensions.

Generated by Expert Code Review (on open) for issue #8815 · sonnet46 1.4M

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.

2 participants