Skip to content

Add MSTEST0035 tests for custom RetryBaseAttribute subclasses - #9923

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/scaling-disco
Jul 14, 2026
Merged

Add MSTEST0035 tests for custom RetryBaseAttribute subclasses#9923
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/scaling-disco

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Fixes#9918

Goal

UseRetryWithTestMethodAnalyzer (MSTEST0035) uses Inherits() to detect any subclass of RetryBaseAttribute — not just the built-in [Retry]. The existing tests only exercised [Retry] directly. This PR adds four tests that exercise the Inherits() path via a user-defined MyRetryAttribute : RetryBaseAttribute subclass.

Coverage

Symbol kindDecorated with TestMethod/TestClass?Expected
MethodNoDiagnostic
MethodYes ([TestMethod])No diagnostic
NamedType (class)NoDiagnostic
NamedType (class)Yes ([TestClass])No diagnostic

The test helper class uses #pragma warning disable MSTESTEXP to suppress the experimental diagnostic on RetryResult/RetryContext, and protected override (matching the base member visibility as seen from an external assembly).

Validation

Built and ran MSTest.Analyzers.UnitTests for both net472 and net8.0 — all tests pass.

Add four tests covering the Inherits() path for custom derived
RetryBaseAttribute subclasses in UseRetryWithTestMethodAnalyzer:
- WhenNonTestMethodHasCustomDerivedRetryAttribute_Diagnostic
- WhenTestMethodHasCustomDerivedRetryAttribute_NoDiagnostic
- WhenNonTestClassHasCustomDerivedRetryAttribute_Diagnostic
- WhenTestClassHasCustomDerivedRetryAttribute_NoDiagnostic
These tests confirm that user-defined RetryBaseAttribute subclasses
are correctly handled by the Inherits() check in the analyzer.
Fixes#9918
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: efa48d3b-7307-4c38-a477-815b089201c5
CopilotAI review requested due to automatic review settings July 14, 2026 07:47

CopilotAI 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 MSTEST0035 coverage for custom RetryBaseAttribute subclasses.

Changes:

  • Tests diagnostic behavior on non-test methods and classes.
  • Tests no-diagnostic behavior on valid test methods and classes.
Show a summary per file
FileDescription
test/UnitTests/MSTest.Analyzers.UnitTests/UseRetryWithTestMethodAnalyzerTests.csAdds four custom retry attribute analyzer tests.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Medium

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jul 14, 2026
@github-actions

This comment has been minimized.

Regenerated via UpdateXlf. The last localized check-in added translations for
'GlobalTestFixtureShouldBeValidClassLayout' (fr) and 'SlowTestStillRunning' (ru)
that XliffTasks rejects (placeholder mismatch), breaking the build with
"xlf is out-of-date with resx". UpdateXlf resets those two units to state="new"
so the build passes; they will be re-translated on the next localization pass.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4350f662-0e5d-4e05-b156-1ef619da3b9e
CopilotAI review requested due to automatic review settings July 14, 2026 07:59

CopilotAI 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.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Medium

- la classe doit être « public »
-La classe doit être marquée avec « [TestClass] » (ou un attribut dérivé).
- la classe ne doit pas être générique.</target>
<target state="new">Methods marked with '[GlobalTestInitialize]' or '[GlobalTestCleanup]' should follow the following layout to be valid:
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9923

GradeTestNotes
A (90–100)new UseRetryWithTestMethodAnalyzerTests.
WhenNonTestClassHasCustomDerivedRetryAttribute_
Diagnostic
Clear AAA; diagnostic location marker verifies exact code-under-analysis and no spurious code fix applied.
A (90–100)new UseRetryWithTestMethodAnalyzerTests.
WhenNonTestMethodHasCustomDerivedRetryAttribute_
Diagnostic
Clear AAA; [|M|] marker pinpoints expected diagnostic; comment explains analyzer behavior being tested.
A (90–100)new UseRetryWithTestMethodAnalyzerTests.
WhenTestClassHasCustomDerivedRetryAttribute_
NoDiagnostic
No issues found.
A (90–100)new UseRetryWithTestMethodAnalyzerTests.
WhenTestMethodHasCustomDerivedRetryAttribute_
NoDiagnostic
No issues found.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
allowed:
- defaults
- "awmgmcpg"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 39.6 AIC · ⌖ 6.48 AIC · ⊞ 8.9K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit bc53c26 into mainJul 14, 2026
35 of 39 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/scaling-disco branch July 14, 2026 09:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test-improver] MSTEST0035: add tests for custom RetryBaseAttribute subclasses

3 participants

@Evangelink@0101