Skip to content

[test-improver] test: add edge case tests for DoNotUseSystemDescriptionAttributeAnalyzer (MSTEST0031)#9020

Draft
Evangelink wants to merge 1 commit into
mainfrom
test-assist/donotuseSystemDescription-edge-cases-58ec96c06026a682
Draft

[test-improver] test: add edge case tests for DoNotUseSystemDescriptionAttributeAnalyzer (MSTEST0031)#9020
Evangelink wants to merge 1 commit into
mainfrom
test-assist/donotuseSystemDescription-edge-cases-58ec96c06026a682

Conversation

@Evangelink

Copy link
Copy Markdown
Member

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

Goal and Rationale

DoNotUseSystemDescriptionAttributeAnalyzer (MSTEST0031) had 5 tests covering the main diagnostic and code-fix paths, but two real-world behaviors were undocumented:

  1. [DataTestMethod] + [System.ComponentModel.Description] → diagnosticDataTestMethodAttribute inherits from TestMethodAttribute. The analyzer detects test methods via attribute.AttributeClass.Inherits(testMethodAttributeSymbol), so [DataTestMethod] should trigger the same diagnostic as [TestMethod]. No test confirmed this inheritance path.

  2. [TestMethod] + MSTest's [Description] → no diagnostic — When using Microsoft.VisualStudio.TestTools.UnitTesting is in scope (without using System.ComponentModel), the short-form [Description] resolves to Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute — the correct attribute. The analyzer checks via SymbolEqualityComparer.Default.Equals(attribute.AttributeClass, systemDescriptionAttributeSymbol) (not Inherits()), so it must not fire here. This test guards against a future regression that might accidentally flag the correct usage.

Approach

Added 2 new [TestMethod] test cases to DoNotUseSystemDescriptionAttributeAnalyzerTests. No production code changes.

Test Status

Test run summary: Passed!
  total: 7
  failed: 0
  succeeded: 7
  skipped: 0
  duration: 8s 605ms

✅ All 7 tests pass (MSTest.Analyzers.UnitTests, net8.0, Debug — 5 original + 2 new).

Reproducibility

./build.sh --restore   # first run only
.dotnet/dotnet test test/UnitTests/MSTest.Analyzers.UnitTests/MSTest.Analyzers.UnitTests.csproj \
  -f net8.0 --no-build -c Debug \
  --filter "ClassName=MSTest.Analyzers.Test.DoNotUseSystemDescriptionAttributeAnalyzerTests"

Trade-offs

  • Tests exercise existing code paths only — no production changes, no maintenance burden beyond the tests.
  • The [DataTestMethod] test pins the Inherits() check behavior for derived test-method attributes.
  • The MSTest [Description] test guards against accidentally flagging the correct usage.

🤖 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.{ai_credits_suffix} · [◷]( · )

Add this agentic workflows to your repo

To install this agentic workflow, run

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

…zer (MSTEST0031)

Add two new test cases:
- [DataTestMethod] + [System.ComponentModel.Description] → diagnostic (confirms
  Inherits() catches attributes derived from TestMethodAttribute)
- [TestMethod] + MSTest's [Description] (no System.ComponentModel using) → no
  diagnostic (resolves to the correct MSTest attribute)

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

This PR expands unit test coverage for the DoNotUseSystemDescriptionAttributeAnalyzer (MSTEST0031) in MSTest.Analyzers.UnitTests by adding two edge-case tests that document and lock in real-world attribute resolution/inheritance behavior.

Changes:

  • Add a new diagnostic + code-fix test ensuring [DataTestMethod] (derived from TestMethodAttribute) is treated as a test method and still triggers MSTEST0031 when using System.ComponentModel.DescriptionAttribute.
  • Add a new “no diagnostic” test ensuring short-form [Description] resolves to MSTest’s Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute when only the MSTest namespace is imported, and is not incorrectly flagged.
Show a summary per file
File Description
test/UnitTests/MSTest.Analyzers.UnitTests/DoNotUseSystemDescriptionAttributeAnalyzerTests.cs Adds two edge-case unit tests covering DataTestMethod inheritance detection and MSTest [Description] short-name resolution without triggering the analyzer.

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