Skip to content

[test-improver] test: add edge case tests for UnusedParameterSuppressor (MSTEST0047)#9301

Draft
Evangelink wants to merge 1 commit into
mainfrom
test-assist/unused-parameter-suppressor-edge-cases-ac3065608b409b3d
Draft

[test-improver] test: add edge case tests for UnusedParameterSuppressor (MSTEST0047)#9301
Evangelink wants to merge 1 commit into
mainfrom
test-assist/unused-parameter-suppressor-edge-cases-ac3065608b409b3d

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Goal and Rationale

UnusedParameterSuppressor (MSTEST0047) suppresses IDE0060 ("Remove unused parameter") when both of these hold:

  1. The parameter type is TestContext
  2. The containing method has [AssemblyInitialize], [ClassInitialize], [GlobalTestInitialize], or [GlobalTestCleanup]

The existing tests verified the positive cases (suppressed) and two negative cases (regular method / non-TestContext in TestMethod). However, the exact boundary conditions — one condition true but not the other — were untested.

Approach

Added two new test methods to UnusedParameterSuppressorTests.cs:

Test Scenario Expected
TestMethodWithUnusedTestContext_DiagnosticIsNotSuppressed [TestMethod] with unused TestContext parameter Not suppressed[TestMethod] is not in the fixture-attribute list
AssemblyInitializeWithUnusedNonTestContextParameter_DiagnosticIsNotSuppressed [AssemblyInitialize] with unused string parameter Not suppressed — only TestContext parameters are eligible

Each test runs twice: once without the suppressor (to confirm the diagnostic fires), and once with the suppressor (to confirm it is not suppressed).

Coverage Impact

These tests target the two independent guard conditions in UnusedParameterSuppressor.ReportSuppressions, ensuring the parameter-type check and the attribute check are each independently exercised with a failing case.

Trade-offs

Minimal — tests follow the existing pattern in the file and add no complexity.

Reproducibility

.dotnet/dotnet test test/UnitTests/MSTest.Analyzers.UnitTests/MSTest.Analyzers.UnitTests.csproj \
  -f net8.0 --no-build -c Debug \
  --filter "FullyQualifiedName~UnusedParameterSuppressorTests"

Test Status

Build: ✅ succeeded (0 warnings, 0 errors)
MSTest.Analyzers.UnitTests (UnusedParameterSuppressorTests): ✅ 8 passed, 0 failed (was 6)

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Test Improver workflow. · 1.7K AIC · ⌖ 23.7 AIC · ⊞ 58K · [◷]( · )

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/test-improver.md@main

Add two missing edge case tests to verify the suppressor's exact boundaries:

1. TestMethodWithUnusedTestContext_DiagnosticIsNotSuppressed: verifies that
   a TestContext parameter in a [TestMethod] (not a fixture attribute) is NOT
   suppressed — [TestMethod] is absent from the suppressor's allowed-attribute
   list.

2. AssemblyInitializeWithUnusedNonTestContextParameter_DiagnosticIsNotSuppressed:
   verifies that a non-TestContext parameter (e.g. string) inside
   [AssemblyInitialize] is NOT suppressed — only TestContext parameters qualify.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 20, 2026 23:36
@Evangelink Evangelink added type/automation Created or maintained by an agentic workflow. type/test-gap Missing or insufficient tests. labels Jun 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds missing boundary-condition coverage for the UnusedParameterSuppressor (MSTEST0047) tests in the MSTest analyzers unit test suite, ensuring the suppressor only applies when both the parameter is TestContext and the containing method is one of the supported fixture lifecycle methods.

Changes:

  • Added a negative test verifying [TestMethod] + unused TestContext is not suppressed.
  • Added a negative test verifying [AssemblyInitialize] + unused non-TestContext parameter is not suppressed.
Show a summary per file
File Description
test/UnitTests/MSTest.Analyzers.UnitTests/UnusedParameterSuppressorTests.cs Adds two edge-case tests to independently exercise the suppressor’s attribute guard and parameter-type guard.

Copilot's findings

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/automation Created or maintained by an agentic workflow. type/test-gap Missing or insufficient tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants