Uh oh!
There was an error while loading. Please reload this page.
test: add edge case tests for AvoidOutRefTestMethodParametersAnalyzer (MSTEST0062) - #9731
Conversation
… (MSTEST0062) Three new tests covering previously-untested code paths: - WhenTestMethodHasDerivedTestMethodAttributeAndOutParam_Diagnostic: exercises the 'Inherits' branch via a custom attribute derived from TestMethodAttribute. - WhenTestMethodOutsideTestClassHasOutParam_Diagnostic: verifies the analyzer fires even without a [TestClass] guard. - WhenTestMethodHasInParameter_NoDiagnostic: verifies 'in' parameters are not flagged (only RefKind.Out/Ref). Fixes#9716 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds three additive unit tests to AvoidOutRefTestMethodParametersAnalyzerTests.cs to cover previously-untested code paths in AvoidOutRefTestMethodParametersAnalyzer (MSTEST0062). There are no production code changes. The new tests exercise the attr.AttributeClass.Inherits(...) branch (custom derived TestMethodAttribute), the absence of a [TestClass] guard, and the fact that in parameters are intentionally not flagged. I verified each test against the analyzer (only RefKind.Out/RefKind.Ref are flagged) and the fixer (which only strips out/ref keywords, leaving the s = ""; bodies valid).
Changes:
- Add
WhenTestMethodHasDerivedTestMethodAttributeAndOutParam_Diagnosticcovering the inheritance-based attribute detection path. - Add
WhenTestMethodOutsideTestClassHasOutParam_Diagnosticconfirming the analyzer fires without a[TestClass]guard. - Add
WhenTestMethodHasInParameter_NoDiagnosticconfirminginparameters are not flagged.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/MSTest.Analyzers.UnitTests/AvoidOutRefTestMethodParametersAnalyzerTests.cs | Adds three edge-case tests; correct and consistent with existing test structure, aside from a minor OutParam vs OutParameter naming inconsistency in two method names. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Medium
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
Review Summary
Result: LGTM — no issues found across all evaluated dimensions.
| Dimension | Verdict |
|---|---|
| Correctness | ✅ Clean |
| Test Isolation | ✅ Clean |
| Assertions | ✅ Clean |
| Flakiness Risk | ✅ Clean |
| Consistency | ✅ Clean |
| Data-Driven / Parameterization | ✅ Clean |
22 dimensions evaluated, 0 findings.
All three new tests correctly exercise previously-untested paths in the analyzer:
- Derived attribute: exercises
Inherits()resolution at analyzer line 58. - Outside TestClass: confirms the analyzer has no
[TestClass]guard (by design — it keys only on[TestMethod]-derived attributes). inparameter: confirms theRefKind.Out or RefKind.Refcheck correctly excludesRefKind.In.
Tests follow established naming, structure, and assertion patterns. No shared state, no flakiness vectors.
Addresses PR review feedback. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🧪 Test quality grade — PR #9731
This advisory comment was generated automatically. Grades are heuristic
|
Uh oh!
There was an error while loading. Please reload this page.
Fixes#9716
Adds three additive tests covering previously-untested paths in
AvoidOutRefTestMethodParametersAnalyzer(MSTEST0062). No production code changes.WhenTestMethodHasDerivedTestMethodAttributeAndOutParam_Diagnosticoutwhen a custom attribute derived fromTestMethodAttributeis used; exercises theattr.AttributeClass.Inherits(...)branchWhenTestMethodOutsideTestClassHasOutParam_Diagnostic[TestClass](no TestClass guard)WhenTestMethodHasInParameter_NoDiagnosticinparameters are not flagged — the analyzer checks onlyRefKind.Out/RefKind.RefTest status
Debug build: 0 warnings, 0 errors.
MSTest.Analyzers.UnitTestspass on bothnet472andnet8.0(7 pre-existing + 3 new).