diff --git a/docs/core/testing/mstest-analyzers/mstest0042.md b/docs/core/testing/mstest-analyzers/mstest0042.md new file mode 100644 index 0000000000000..f4a05e30dd534 --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0042.md @@ -0,0 +1,41 @@ +--- +title: "MSTEST0042: Avoid duplicated 'DataRow' entries" +description: "Learn about code analysis rule MSTEST0042: Avoid duplicated 'DataRow' entries" +ms.date: 04/11/2025 +f1_keywords: +- MSTEST0042 +- DuplicateDataRowAnalyzer +helpviewer_keywords: +- DuplicateDataRowAnalyzer +- MSTEST0042 +author: Youssef1313 +ms.author: ygerges +--- +# MSTEST0042: Avoid duplicated 'DataRow' entries + +| Property | Value | +|-------------------------------------|------------------------------------------------------------------------| +| **Rule ID** | MSTEST0042 | +| **Title** | Avoid duplicated 'DataRow' entries | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Warning | +| **Introduced in version** | 3.9.0 | +| **Is there a code fix** | No | + +## Cause + +A test method has two or more [DataRow](xref:Microsoft.VisualStudio.TestTools.UnitTesting.DataRowAttribute) attributes that are equivalent. + +## Rule description + + is used to denote inputs to test methods. It's not expected that a test will intentionally run twice with the exact same data. Duplicated `DataRow`s are often a copy/paste error. + +## How to fix violations + +Either remove the duplicate `DataRow` attribute, or fix it to make unique. + +## When to suppress warnings + +Do not suppress a warning from this rule, unless you intended to use the same input more than once. diff --git a/docs/core/testing/mstest-analyzers/mstest0043.md b/docs/core/testing/mstest-analyzers/mstest0043.md new file mode 100644 index 0000000000000..914e17e0d4128 --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0043.md @@ -0,0 +1,41 @@ +--- +title: "MSTEST0043: Use retry attribute on test method" +description: "Learn about code analysis rule MSTEST0043: Use retry attribute on test method" +ms.date: 04/11/2025 +f1_keywords: +- MSTEST0043 +- UseRetryWithTestMethodAnalyzer +helpviewer_keywords: +- UseRetryWithTestMethodAnalyzer +- MSTEST0043 +author: Youssef1313 +ms.author: ygerges +--- +# MSTEST0043: Use retry attribute on test method + +| Property | Value | +|-------------------------------------|------------------------------------------------------------------------------------------| +| **Rule ID** | MSTEST0043 | +| **Title** | Use retry attribute on test method | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Warning (escalated to Error when setting `MSTestAnalysisMode` to `Recommended` or `All`) | +| **Introduced in version** | 3.9.0 | +| **Is there a code fix** | No | + +## Cause + +A method has an attribute that derives from and does not have an attribute that derives from . + +## Rule description + + only applies to test methods. + +## How to fix violations + +Add to the method, or remove the . + +## When to suppress warnings + +Do not suppress a warning from this rule. diff --git a/docs/core/testing/mstest-analyzers/overview.md b/docs/core/testing/mstest-analyzers/overview.md index d8bd11d084fe9..04df8a6d0c1b9 100644 --- a/docs/core/testing/mstest-analyzers/overview.md +++ b/docs/core/testing/mstest-analyzers/overview.md @@ -49,11 +49,17 @@ This setting follows the default documented behavior for each rule. ### `Recommended` -This is the mode we expect most developers to use. Rules that are enabled by default with Info (`suggestion`) severity are escalated to warnings. Moreover, certain rules might be escalated to errors in both `Recommended` and `All` modes. For example, [MSTEST0003: Test methods should have valid layout](mstest0003.md) is escalated to error in `Recommended` and `All` modes. +This is the mode most developers are expected to use. Rules that are enabled by default with Info (`suggestion`) severity are escalated to warnings. The following rules are escalated to errors in both `Recommended` and `All` modes: + +- [MSTEST0003: Test methods should have valid layout](mstest0003.md). +- [MSTEST0043: Use retry attribute on test method](mstest0043.md). ### `All` -This mode is more aggressive than `Recommended`. All rules are enabled as warnings. As mentioned for `Recommended` mode, certain rules might be escalated to errors in both `Recommended` and `All` modes. For example, [MSTEST0003: Test methods should have valid layout](./mstest0003.md) is escalated to error in `Recommended` and `All` modes. +This mode is more aggressive than `Recommended`. All rules are enabled as warnings. In addition, the following rules are escalated to errors: + +- [MSTEST0003: Test methods should have valid layout](mstest0003.md). +- [MSTEST0043: Use retry attribute on test method](mstest0043.md). > [!NOTE] > The following rules are completely opt-in and are not enabled in `Default`, `Recommended`, or `All` modes: diff --git a/docs/core/testing/mstest-analyzers/usage-rules.md b/docs/core/testing/mstest-analyzers/usage-rules.md index 120458aad2c48..8f6723072467a 100644 --- a/docs/core/testing/mstest-analyzers/usage-rules.md +++ b/docs/core/testing/mstest-analyzers/usage-rules.md @@ -38,3 +38,5 @@ Identifier | Name | Description [MSTEST0039](mstest0039.md) | UseNewerAssertThrowsAnalyzer | Use newer 'Assert.Throws' methods [MSTEST0040](mstest0040.md) | AvoidUsingAssertsInAsyncVoidContextAnalyzer | Do not assert inside 'async void' contexts [MSTEST0041](mstest0041.md) | UseConditionBaseWithTestClassAnalyzer | Use 'ConditionBaseAttribute' on test classes +[MSTEST0042](mstest0042.md) | DuplicateDataRowAnalyzer | Avoid duplicated 'DataRow' entries +[MSTEST0043](mstest0043.md) | UseRetryWithTestMethodAnalyzer | Use retry attribute on test method diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml index 03a0fff1e4bb1..96cf78d381915 100644 --- a/docs/navigate/devops-testing/toc.yml +++ b/docs/navigate/devops-testing/toc.yml @@ -207,6 +207,10 @@ items: href: ../../core/testing/mstest-analyzers/mstest0040.md - name: MSTEST0041 href: ../../core/testing/mstest-analyzers/mstest0041.md + - name: MSTEST0042 + href: ../../core/testing/mstest-analyzers/mstest0042.md + - name: MSTEST0043 + href: ../../core/testing/mstest-analyzers/mstest0043.md - name: Test platforms items: - name: Microsoft.Testing.Platform