Skip to content

Commit 88f778f

Browse files
authored
Doc MSTEST0041 analyzer (#44882)
1 parent c7f755f commit 88f778f

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

docs/core/testing/mstest-analyzers/mstest0007.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ A method that's not marked with <xref:Microsoft.VisualStudio.TestTools.UnitTesti
3232

3333
The following test attributes should only be applied on methods marked with the <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute> attribute:
3434

35+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.ConditionBaseAttribute>
3536
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.CssIterationAttribute>
3637
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.CssProjectStructureAttribute>
3738
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute>
38-
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.ExpectedExceptionAttribute>
39+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.ExpectedExceptionBaseAttribute>
3940
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.OwnerAttribute>
4041
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.PriorityAttribute>
4142
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: "MSTEST0041: Use 'ConditionBaseAttribute' on test classes"
3+
description: "Learn about code analysis rule MSTEST0041: Use 'ConditionBaseAttribute' on test classes"
4+
ms.date: 02/13/2025
5+
f1_keywords:
6+
- MSTEST0041
7+
- UseConditionBaseWithTestClassAnalyzer
8+
helpviewer_keywords:
9+
- UseConditionBaseWithTestClassAnalyzer
10+
- MSTEST0041
11+
author: Youssef1313
12+
ms.author: ygerges
13+
---
14+
# MSTEST0041: Use 'ConditionBaseAttribute' on test classes
15+
16+
| Property | Value |
17+
|-------------------------------------|------------------------------------------------------------------------|
18+
| **Rule ID** | MSTEST0041 |
19+
| **Title** | Use 'ConditionBaseAttribute' on test classes |
20+
| **Category** | Usage |
21+
| **Fix is breaking or non-breaking** | Non-breaking |
22+
| **Enabled by default** | Yes |
23+
| **Default severity** | Warning |
24+
| **Introduced in version** | 3.8.0 |
25+
| **Is there a code fix** | No |
26+
27+
## Cause
28+
29+
The use of an attribute that inherits from <xref:Microsoft.VisualStudio.TestTools.UnitTesting.ConditionBaseAttribute> on a class that is not marked with <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute>.
30+
31+
## Rule description
32+
33+
An attribute that derives from <xref:Microsoft.VisualStudio.TestTools.UnitTesting.ConditionBaseAttribute> only has an effect when applied to a class that's marked with <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute>.
34+
35+
## How to fix violations
36+
37+
Depending on the intent, either add the missing <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute> or remove the attribute that derives from <xref:Microsoft.VisualStudio.TestTools.UnitTesting.ConditionBaseAttribute>.
38+
39+
## When to suppress warnings
40+
41+
Do not suppress a warning from this rule.

docs/core/testing/mstest-analyzers/usage-rules.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ Identifier | Name | Description
3737
[MSTEST0038](mstest0038.md) | AvoidAssertAreSameWithValueTypesAnalyzer | Don't use `Assert.AreSame` or `Assert.AreNotSame` with value types
3838
[MSTEST0039](mstest0039.md) | UseNewerAssertThrowsAnalyzer | Use newer 'Assert.Throws' methods
3939
[MSTEST0040](mstest0040.md) | AvoidUsingAssertsInAsyncVoidContextAnalyzer | Do not assert inside 'async void' contexts
40+
[MSTEST0041](mstest0041.md) | UseConditionBaseWithTestClassAnalyzer | Use 'ConditionBaseAttribute' on test classes

docs/navigate/devops-testing/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ items:
197197
href: ../../core/testing/mstest-analyzers/mstest0039.md
198198
- name: MSTEST0040
199199
href: ../../core/testing/mstest-analyzers/mstest0040.md
200+
- name: MSTEST0041
201+
href: ../../core/testing/mstest-analyzers/mstest0041.md
200202
- name: Microsoft Testing Platform
201203
items:
202204
- name: Overview

0 commit comments

Comments
 (0)