You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AvoidOutRefTestMethodParametersAnalyzer (MSTEST0062) had 7 tests covering the direct happy-path scenarios. Three distinct guard/classification paths in the analyzer were not yet covered by tests:
Analyzer fires + fixer removes out when a custom attribute derived from TestMethodAttribute is used instead of [TestMethod] directly; exercises the Inherits branch
🤖 Automated content by GitHub Copilot. Generated by the Test Improver workflow. · 168.3 AIC · ⌖ 16.3 AIC · ⊞ 13K · [◷]( · ◷)
Add this agentic workflows to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/test-improver.md@main
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch test-assist/avoid-out-ref-edge-cases-9c17117d3f8f0d79.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (131 of 131 lines)
From af26c774a8713cb68394426719c2d742adecfce5 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Tue, 7 Jul 2026 23:24:17 +0000
Subject: [PATCH] test: add edge case tests for
AvoidOutRefTestMethodParametersAnalyzer (MSTEST0062)
Three new tests covering previously-untested code paths:
- WhenTestMethodHasDerivedTestMethodAttributeAndOutParam_Diagnostic:
verify the analyzer fires (and fixer removes 'out') when the test method
carries a custom attribute derived from TestMethodAttribute rather than
TestMethodAttribute directly; exercises the 'Inherits' branch.
- WhenTestMethodOutsideTestClassHasOutParam_Diagnostic:
verify the analyzer fires even when the containing class has no
[TestClass] attribute (the analyzer has no TestClass guard).
- WhenTestMethodHasInParameter_NoDiagnostic:
verify 'in' parameters are not flagged; the analyzer explicitly checks
only RefKind.Out and RefKind.Ref.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
...OutRefTestMethodParametersAnalyzerTests.cs | 92 +++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/test/UnitTests/MSTest.Analyzers.UnitTests/AvoidOutRefTestMethodParametersAnalyzerTests.cs b/test/UnitTests/MSTest.Analyzers.UnitTests/AvoidOutRefTestMethodParametersAnalyzerTests.cs
index b1dd593..0b7bb28 100644
--- a/test/UnitTests/MSTest.Analyzers.UnitTests/AvoidOutRefTestMethodParametersAnalyzerTests.cs+++ b/test/UnitTests/MSTest.Analyzers.UnitTests/AvoidOutRefTestMethodParametersAnalyzerTests.cs@@ -230,4 +230,96 @@ public void TestMethod1(string s)
await VerifyCS.VerifyCodeFixAsync(code, fixedCode);
}
++ [TestMethod]+ public async Task WhenTestMethodHasDerivedTestMethodAttributeAndOutParam_Diagnostic()+ {+ string code = """+ using Microsoft.VisualStudio.TestTools.UnitTesting;++ public sealed class MyCustomTestMethodAttribute : TestMethodAttribute { }++
... (truncated)
Goal and Rationale
AvoidOutRefTestMethodParametersAnalyzer(MSTEST0062) had 7 tests covering the direct happy-path scenarios. Three distinct guard/classification paths in the analyzer were not yet covered by tests:TestMethodAttributeinheritance checkattr.AttributeClass.Inherits(testMethodAttributeSymbol)[TestClass]guard (fires outside test classes)RefKind.Innot flaggedp.RefKind is RefKind.Out or RefKind.RefApproach
Three additive tests, no production code changes:
WhenTestMethodHasDerivedTestMethodAttributeAndOutParam_Diagnosticoutwhen a custom attribute derived fromTestMethodAttributeis used instead of[TestMethod]directly; exercises theInheritsbranchWhenTestMethodOutsideTestClassHasOutParam_Diagnostic[TestClass](no TestClass guard); fixer still appliesWhenTestMethodHasInParameter_NoDiagnosticinparameters are not flagged — the analyzer explicitly checks onlyRefKind.OutandRefKind.RefTest Status
Debug build: 0 warnings, 0 errors.
AvoidOutRefTestMethodParametersAnalyzerTestsonnet8.0: 10/10 passed (7 pre-existing + 3 new).Add this agentic workflows to your repo
To install this agentic workflow, run
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
test-assist/avoid-out-ref-edge-cases-9c17117d3f8f0d79.Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (131 of 131 lines)