Skip to content

[test-improver] test: add edge case tests for TestMethodShouldNotBeIgnoredAnalyzer (MSTEST0015)#8869

Merged
Evangelink merged 2 commits into
mainfrom
test-assist/test-method-should-not-be-ignored-edge-cases-22b6591001706ab8
Jun 7, 2026
Merged

[test-improver] test: add edge case tests for TestMethodShouldNotBeIgnoredAnalyzer (MSTEST0015)#8869
Evangelink merged 2 commits into
mainfrom
test-assist/test-method-should-not-be-ignored-edge-cases-22b6591001706ab8

Conversation

@Evangelink
Copy link
Copy Markdown
Member

🤖 Test Improver — automated AI assistant focused on improving tests for this repository.

Goal and Rationale

TestMethodShouldNotBeIgnoredAnalyzer (MSTEST0015) had only 4 tests. Three important behavioral boundaries were untested:

  1. How the analyzer handles [DataTestMethod] (a TestMethodAttribute derivative paired with [Ignore])
  2. Whether a class with mixed ignored/non-ignored methods produces one diagnostic or two
  3. Whether a class-level [Ignore] (without method-level) triggers the rule
  4. Whether an [Ignore] with a justification message still fires MSTEST0015 (vs. MSTEST0014)

These are the scenarios users most commonly ask about when enabling this rule.

Approach

Added four new tests:

Test Condition exercised
WhenDataTestMethodIsIgnored_Diagnostic [DataTestMethod] is a TestMethodAttribute derivative — it should be treated like [TestMethod]
WhenMultipleTestMethodsAndOnlyOneIsIgnored_DiagnosticOnlyForIgnoredMethod Only the method bearing [Ignore] gets a diagnostic; the un-ignored sibling is clean
WhenOnlyClassLevelIgnoreWithNoMethodLevelIgnore_NoDiagnostic MSTEST0015 inspects method-level attributes only — class-level [Ignore] doesn't fire it
WhenIgnoredTestMethodHasMessage_Diagnostic A justification message satisfies MSTEST0014 but MSTEST0015 still fires — the test is still ignored

Trade-offs

Minimal maintenance burden — straightforward analyzer verifications with no mocking or state.

Test Status

✅ All 8 tests passed (MSTest.Analyzers.UnitTests net8.0, 0 warnings, 0 errors)

total: 8 | failed: 0 | succeeded: 8 | skipped: 0 | duration: 7.5s

Reproducibility

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

Generated by Test Improver · sonnet46 4.6M ·

Add this agentic workflows to your repo

To install this agentic workflow, run

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

…STEST0015)

Add four new test cases that document and verify distinct behavioral
edges of the MSTEST0015 analyzer:

- WhenDataTestMethodIsIgnored_Diagnostic: [DataTestMethod] is a
  TestMethod derivative and should trigger MSTEST0015 when paired
  with [Ignore].

- WhenMultipleTestMethodsAndOnlyOneIsIgnored_DiagnosticOnlyForIgnoredMethod:
  only the method that bears [Ignore] receives the diagnostic; the
  un-ignored sibling method is clean.

- WhenOnlyClassLevelIgnoreWithNoMethodLevelIgnore_NoDiagnostic:
  MSTEST0015 inspects method-level attributes only, so a class-level
  [Ignore] without any method-level [Ignore] does not fire.

- WhenIgnoredTestMethodHasMessage_Diagnostic: providing a justification
  message in [Ignore("...")]] satisfies MSTEST0014
  (IgnoreShouldHaveJustification) but MSTEST0015 still fires because
  the test remains ignored.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 23:35
@Evangelink Evangelink added type/automation Created or maintained by an agentic workflow. type/test-gap Missing or insufficient tests. labels Jun 5, 2026
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 expands the unit test coverage for the TestMethodShouldNotBeIgnoredAnalyzer (MSTEST0015) in MSTest.Analyzers by adding new edge-case scenarios to clarify intended analyzer behavior around ignored tests.

Changes:

  • Added a test ensuring [DataTestMethod] with [Ignore] still triggers MSTEST0015.
  • Added a test verifying only the ignored method is diagnosed when a class has mixed ignored/non-ignored test methods.
  • Added a test confirming class-level [Ignore] alone does not trigger MSTEST0015.
  • Added a test confirming [Ignore("...")] (with justification) still triggers MSTEST0015.
Show a summary per file
File Description
test/UnitTests/MSTest.Analyzers.UnitTests/TestMethodShouldNotBeIgnoredAnalyzerTests.cs Adds 4 new analyzer tests covering [DataTestMethod], mixed ignored/non-ignored methods, class-level ignore behavior, and ignore-with-message behavior.

Copilot's findings

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

@Evangelink Evangelink marked this pull request as ready for review June 6, 2026 14:05
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink Evangelink merged commit daccc20 into main Jun 7, 2026
47 checks passed
@Evangelink Evangelink deleted the test-assist/test-method-should-not-be-ignored-edge-cases-22b6591001706ab8 branch June 7, 2026 11:09
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