Implement MSTest v4 analyzer suggestions: parallelization, assertion order, and specific assertions#9
Merged
markhazleton merged 1 commit intoMar 20, 2026
Conversation
Copilot
AI
changed the title
[WIP] Implement MSTest v4 code quality analyzer suggestions
Implement MSTest v4 analyzer suggestions: parallelization, assertion order, and specific assertions
Mar 20, 2026
markhazleton
marked this pull request as ready for review
March 20, 2026 12:26
markhazleton
added a commit
that referenced
this pull request
Mar 30, 2026
…nalyzer-suggestions Implement MSTest v4 analyzer suggestions: parallelization, assertion order, and specific assertions
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.
MSTest v4.x ships with analyzers that flag 7 issues across the test project — argument order violations (MSTEST0017), generic assertions where specific ones exist (MSTEST0037), and missing explicit parallelization config (MSTEST0001).
Changes
AssemblyInfo.cs— MSTEST0001Added explicit parallelization configuration:
StrongDictionaryTests.cs— MSTEST0017 + MSTEST0037expected/actualarguments on lines 59 and 72Assert.AreEqual(5, collection.Count)→Assert.HasCount(5, collection)(line 18)Assert.AreNotEqual(null, obj)→Assert.IsNotNull(obj)(lines 100, 110)String_ExtensionsTests.cs— MSTEST0017expected/actualargument order (line 55)Result
Build produces 0 MSTEST warnings; all 21 tests pass at 100%.
Original prompt
This section details on the original issue you should resolve
<issue_title>Implement MSTest v4 code quality analyzer suggestions</issue_title>
<issue_description>## Overview
MSTest v4 introduces enhanced code analyzers that provide 7 actionable suggestions to improve test code quality. These are currently appearing as warnings but represent opportunities to enhance test maintainability and diagnostic clarity.
Current Status
Analyzer Warnings to Address
1. MSTEST0001: Configure Test Parallelization (1 instance)
Location: Assembly level
Current: Tests run sequentially by default (no explicit configuration)
Recommendation: Add explicit parallelization configuration
Suggested Fix:
Benefit: Explicitly documents parallelization strategy, enables future optimization
2. MSTEST0017: Fix Assertion Argument Order (3 instances)
Locations:
StrongDictionaryTests.csline 59StrongDictionaryTests.csline 72String_ExtensionsTests.csline 55Issue: Expected and actual arguments are swapped, leading to confusing error messages
Example of Current (Incorrect) Pattern:
Correct Pattern:
Benefit: Better error messages when tests fail - clearly shows expected vs actual values
3. MSTEST0037: Use Specific Assertion Methods (3 instances)
Locations:
StrongDictionaryTests.csline 18: UseAssert.HasCountinstead ofAssert.AreEqualStrongDictionaryTests.csline 100: UseAssert.IsNotNullinstead ofAssert.AreNotEqualStrongDictionaryTests.csline 110: UseAssert.IsNotNullinstead ofAssert.AreNotEqualCurrent Pattern:
Improved Pattern:
Benefit: More descriptive test failures, clearer intent, better IDE integration
Implementation Plan
Phase 1: Assembly-Level Configuration (5 minutes)
AssemblyInfo.csin RESTRunner.Domain.Tests[assembly: Parallelize(...)]attributePhase 2: Fix Assertion Argument Order (10-15 minutes)
StrongDictionaryTests.csAssert.AreEqualAssert.AreEqualString_ExtensionsTests.csAssert.AreEqualPhase 3: Update to Specific Assertions (10-15 minutes)
StrongDictionaryTests.csAssert.AreEqual(count, dict.Count)withAssert.HasCount(count, dict)Assert.AreNotEqual(null, obj)withAssert.IsNotNull(obj)Assert.AreNotEqual(null, obj)withAssert.IsNotNull(obj)Phase 4: Validation (5 minutes)
dotnet build --configuration Releasedotnet testAcceptance Criteria
Benefits
Estimated Effort
Total Time: 30-60 minutes
Complexity: Low
Risk: Very Low (all tests currently passing)
Related
Notes
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.