diff --git a/docs/core/testing/mstest-analyzers/mstest0055.md b/docs/core/testing/mstest-analyzers/mstest0055.md index 209244376392f..2ce2d907c9f58 100644 --- a/docs/core/testing/mstest-analyzers/mstest0055.md +++ b/docs/core/testing/mstest-analyzers/mstest0055.md @@ -27,7 +27,7 @@ ai-usage: ai-generated ## Cause -A call to `string.Contains`, `string.StartsWith`, or `string.EndsWith` is made and its return value is ignored. +A call to , , or is made and its return value is ignored. ## Rule description diff --git a/docs/core/testing/mstest-analyzers/mstest0056.md b/docs/core/testing/mstest-analyzers/mstest0056.md new file mode 100644 index 0000000000000..1a713d92936ef --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0056.md @@ -0,0 +1,87 @@ +--- +title: "MSTEST0056: Use DisplayName property for test method display names" +description: "Learn about code analysis rule MSTEST0056: Use DisplayName property for test method display names" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0056 +- TestMethodAttributeShouldSetDisplayNameCorrectlyAnalyzer +helpviewer_keywords: +- TestMethodAttributeShouldSetDisplayNameCorrectlyAnalyzer +- MSTEST0056 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0056: Use DisplayName property for test method display names + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0056 | +| **Title** | Use DisplayName property for test method display names | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Warning | +| **Introduced in version** | 4.0.0 | +| **Is there a code fix** | Yes | + +## Cause + +A test method attribute uses a string constructor argument instead of the property. + +## Rule description + +When specifying a custom display name for a test method, you should use the property instead of passing a string as a constructor argument. In MSTest 4.0 and later, the string constructor argument is used for source information (caller file path) rather than display name, which is a breaking change from MSTest 3.x. Using the `DisplayName` property ensures your code works correctly and avoids potential confusion. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod("My Test Name")] // Violation + public void TestMethod() + { + // Test code + } +} +``` + +## How to fix violations + +Replace the constructor argument with the `DisplayName` property. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod(DisplayName = "My Test Name")] + public void TestMethod() + { + // Test code + } +} +``` + +## When to suppress warnings + +Do not suppress warnings from this rule. Using the `DisplayName` property is the only way to specify custom display names for test methods. If your intent is to explicitly pass a value for the caller file path parameter instead of setting a display name, you can suppress this warning, but this is rarely needed. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0056 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0056 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0056.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/mstest0057.md b/docs/core/testing/mstest-analyzers/mstest0057.md new file mode 100644 index 0000000000000..b316327ce66c2 --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0057.md @@ -0,0 +1,87 @@ +--- +title: "MSTEST0057: Propagate source information in custom test method attributes" +description: "Learn about code analysis rule MSTEST0057: Propagate source information in custom test method attributes" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0057 +- TestMethodAttributeShouldPropagateSourceInformationAnalyzer +helpviewer_keywords: +- TestMethodAttributeShouldPropagateSourceInformationAnalyzer +- MSTEST0057 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0057: Propagate source information in custom test method attributes + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0057 | +| **Title** | Propagate source information in custom test method attributes | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Warning | +| **Introduced in version** | 4.0.0 | +| **Is there a code fix** | Yes | + +## Cause + +A custom class does not propagate caller information to the base class constructor. + +## Rule description + +When creating custom test method attributes that derive from , you should propagate source information using caller information attributes. This allows MSTest to correctly track the source file and line number for test methods, improving diagnostics, test result reporting, and Test Explorer behavior. + +```csharp +public class MyTestMethodAttribute : TestMethodAttribute +{ + public MyTestMethodAttribute() // Violation + : base() + { + } +} +``` + +## How to fix violations + +Add `CallerFilePath` and `CallerLineNumber` parameters to the constructor and pass them to the base class. + +```csharp +using System.Runtime.CompilerServices; + +public class MyTestMethodAttribute : TestMethodAttribute +{ + public MyTestMethodAttribute( + [CallerFilePath] string callerFilePath = "", + [CallerLineNumber] int callerLineNumber = -1) + : base(callerFilePath, callerLineNumber) + { + } +} +``` + +## When to suppress warnings + +Do not suppress warnings from this rule. Propagating source information is essential for proper test reporting and diagnostics. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0057 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0057 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0057.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/mstest0058.md b/docs/core/testing/mstest-analyzers/mstest0058.md new file mode 100644 index 0000000000000..08dd30cc21aaa --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0058.md @@ -0,0 +1,98 @@ +--- +title: "MSTEST0058: Avoid assertions in catch blocks" +description: "Learn about code analysis rule MSTEST0058: Avoid assertions in catch blocks" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0058 +- AvoidAssertsInCatchBlocksAnalyzer +helpviewer_keywords: +- AvoidAssertsInCatchBlocksAnalyzer +- MSTEST0058 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0058: Avoid assertions in `catch` blocks + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0058 | +| **Title** | Avoid assertions in catch blocks | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Info | +| **Introduced in version** | 4.1.0 | +| **Is there a code fix** | No | + +## Cause + +A test method contains assertion statements within a `catch` block. + +## Rule description + +Placing assertions in `catch` blocks is an anti-pattern that can lead to confusing test results and makes tests harder to understand. When an exception is thrown, the `catch` block executes, and the assertion runs. However, if no exception is thrown, the `catch` block never executes, potentially giving false confidence that the test passed. + +Instead, use or similar methods to verify that expected exceptions are thrown. This makes the test intent clearer and ensures proper test behavior. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethod() + { + try + { + // Code that might throw. + DoSomethingThatMightThrow(); + } + catch (Exception ex) + { + Assert.AreEqual("Expected error message", ex.Message); // Violation + } + } +} +``` + +## How to fix violations + +Use `Assert.Throws`, `Assert.ThrowsExactly` or related assertion methods to test for exceptions. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethod_ThrowsExceptionWithExpectedMessage() + { + InvalidOperationException exception = Assert.Throws(() => DoSomethingThatMightThrow()); + Assert.AreEqual("Expected error message", exception.Message); + } +} +``` + +## When to suppress warnings + +You might suppress this warning if you have a legitimate need to catch an exception and perform complex validation that cannot be easily expressed using standard assertion methods. However, consider refactoring your test to use more explicit exception assertions first. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0058 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0058 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0058.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/mstest0059.md b/docs/core/testing/mstest-analyzers/mstest0059.md new file mode 100644 index 0000000000000..c3e38615844e9 --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0059.md @@ -0,0 +1,113 @@ +--- +title: "MSTEST0059: Do not use both Parallelize and DoNotParallelize attributes" +description: "Learn about code analysis rule MSTEST0059: Do not use both Parallelize and DoNotParallelize attributes" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0059 +- UseParallelizeAttributeAnalyzer +helpviewer_keywords: +- UseParallelizeAttributeAnalyzer +- MSTEST0059 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0059: Do not use both Parallelize and DoNotParallelize attributes + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0059 | +| **Title** | Do not use both Parallelize and DoNotParallelize attributes | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Warning | +| **Introduced in version** | 4.1.0 | +| **Is there a code fix** | No | + +## Cause + +An assembly contains both and attributes. + +## Rule description + +The and attributes are mutually exclusive at the assembly level. When both attributes are applied to the same assembly, tests run sequentially. This conflicting configuration indicates unclear intent and should be resolved by choosing one parallelization strategy for your test assembly. + +```csharp +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] // Violation +[assembly: DoNotParallelize] +``` + +## How to fix violations + +Remove one of the conflicting attributes based on your intended parallelization strategy. + +If you want parallel execution: + +```csharp +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] +``` + +If you want sequential execution: + +```csharp +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[assembly: DoNotParallelize] +``` + +If you want to enable parallelization at the assembly level but disable it for specific classes or methods, apply `Parallelize` at the assembly level and `DoNotParallelize` at the class or method level: + +```csharp +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)] + +[DoNotParallelize] +[TestClass] +public class SequentialTests +{ + [TestMethod] + public void Test1() { } +} + +[TestClass] +public class ParallelTests +{ + [TestMethod] + public void Test2() { } + + [DoNotParallelize] + [TestMethod] + public void Test3() { } +} +``` + +## When to suppress warnings + +Do not suppress warnings from this rule. Having both attributes creates ambiguous test configuration that should be resolved. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0059 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0059 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0059.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/mstest0060.md b/docs/core/testing/mstest-analyzers/mstest0060.md new file mode 100644 index 0000000000000..63a6256ec2656 --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0060.md @@ -0,0 +1,88 @@ +--- +title: "MSTEST0060: Avoid duplicate test method attributes" +description: "Learn about code analysis rule MSTEST0060: Avoid duplicate test method attributes" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0060 +- DuplicateTestMethodAttributeAnalyzer +helpviewer_keywords: +- DuplicateTestMethodAttributeAnalyzer +- MSTEST0060 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0060: Avoid duplicate test method attributes + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0060 | +| **Title** | Avoid duplicate test method attributes | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Warning | +| **Introduced in version** | 4.1.0 | +| **Is there a code fix** | No | + +## Cause + +A test method has multiple declarations. + +## Rule description + +A test method should have only one attribute that derives from . Having multiple test method attributes (such as `[TestMethod]` and `[UITestMethod]`) on the same method causes only one attribute to be used (the first one returned by reflection), which can be confusing and lead to unintended test execution. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + [UITestMethod] // Violation + public void TestMethod1() + { + // Test code + } +} +``` + +## How to fix violations + +Remove the duplicate attribute and keep only the one that matches your test method's purpose. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethod1() + { + // Test code + } +} +``` + +## When to suppress warnings + +Do not suppress warnings from this rule. Having multiple test method attributes creates ambiguous test configuration where only one attribute is used, which can cause confusion about which test behavior is actually applied. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0060 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0060 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0060.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/mstest0061.md b/docs/core/testing/mstest-analyzers/mstest0061.md new file mode 100644 index 0000000000000..94bb055743dbf --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0061.md @@ -0,0 +1,115 @@ +--- +title: "MSTEST0061: Use OSCondition attribute instead of runtime checks" +description: "Learn about code analysis rule MSTEST0061: Use OSCondition attribute instead of runtime checks" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0061 +- UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzer +helpviewer_keywords: +- UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzer +- MSTEST0061 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0061: Use OSCondition attribute instead of runtime checks + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0061 | +| **Title** | Use OSCondition attribute instead of runtime checks | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Info | +| **Introduced in version** | 4.1.0 | +| **Is there a code fix** | Yes | + +## Cause + +A test method uses checks with an early return instead of the attribute. + +## Rule description + +When you want to skip tests based on the operating system, use the attribute instead of manual runtime checks. The attribute approach provides better test discoverability and clearer test intent, and integrates properly with test frameworks to mark tests as skipped rather than passed. + +```csharp +using System.Runtime.InteropServices; + +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethod() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // Violation + { + return; + } + + // Test code that requires Windows + } +} +``` + +## How to fix violations + +Replace the runtime check with the `[OSCondition]` attribute. + +```csharp +using Microsoft.VisualStudio.TestTools.UnitTesting; + +[TestClass] +public class TestClass +{ + [TestMethod] + [OSCondition(OperatingSystems.Windows)] + public void TestMethod() + { + // Test code that requires Windows + } +} +``` + +The `[OSCondition]` attribute supports the following operating systems: + +- `OperatingSystems.Linux` +- `OperatingSystems.OSX` (macOS) +- `OperatingSystems.Windows` +- `OperatingSystems.FreeBSD` + +You can also combine multiple operating systems using bitwise `OR`: + +```csharp +[TestMethod] +[OSCondition(OperatingSystems.Windows | OperatingSystems.Linux)] +public void TestMethod() +{ + // Test code that requires Windows or Linux +} +``` + +## When to suppress warnings + +You might suppress this warning if your runtime check is more complex than a simple early return pattern, or if you need to perform conditional logic that cannot be expressed using the `[OSCondition]` attribute. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0061 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0061 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0061.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/mstest0062.md b/docs/core/testing/mstest-analyzers/mstest0062.md new file mode 100644 index 0000000000000..9d29709fe764b --- /dev/null +++ b/docs/core/testing/mstest-analyzers/mstest0062.md @@ -0,0 +1,136 @@ +--- +title: "MSTEST0062: Avoid out and ref parameters in test methods" +description: "Learn about code analysis rule MSTEST0062: Avoid out and ref parameters in test methods" +ms.date: 12/29/2025 +f1_keywords: +- MSTEST0062 +- AvoidOutRefTestMethodParametersAnalyzer +helpviewer_keywords: +- AvoidOutRefTestMethodParametersAnalyzer +- MSTEST0062 +author: evangelink +ms.author: amauryleve +ai-usage: ai-assisted +dev_langs: +- CSharp +--- +# MSTEST0062: Avoid out and ref parameters in test methods + +| Property | Value | +|-------------------------------------|----------------------------------------------------| +| **Rule ID** | MSTEST0062 | +| **Title** | Avoid out and ref parameters in test methods | +| **Category** | Usage | +| **Fix is breaking or non-breaking** | Non-breaking | +| **Enabled by default** | Yes | +| **Default severity** | Info | +| **Introduced in version** | 4.1.0 | +| **Is there a code fix** | Yes | + +## Cause + +A test method has parameters marked with `out` or `ref` modifiers. + +## Rule description + +Test methods should not have `out` or `ref` parameters. MSTest is responsible for calling test methods, and it never reads the values that are passed by reference after the test method finishes. These modifiers are misleading because they suggest the test method returns values that will be used, but MSTest never uses them after the test completes. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethod(out string s, ref string s2) // Violation + { + s = "test"; + } +} +``` + +## How to fix violations + +Remove the `out` and `ref` modifiers from test method parameters. + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethod() + { + // Test code + } +} +``` + +If you need to test methods with `out` or `ref` parameters, call them from within your test method: + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + public void TestMethodWithOutParameter() + { + // Arrange + string result; + string passedByRef = "some value"; + var instance = new MyClass(); + + // Act + bool success = instance.TryGetValue(out result, ref passedByRef); + + // Assert + Assert.IsTrue(success); + Assert.AreEqual("expected", result); + } +} +``` + +For data-driven tests: + +```csharp +[TestClass] +public class TestClass +{ + [TestMethod] + [DataRow("input1", "expected1")] + [DataRow("input2", "expected2")] + public void TestMethod(string input, string expected) + { + // Arrange + string result; + var instance = new MyClass(); + + // Act + bool success = instance.TryParse(input, out result); + + // Assert + Assert.IsTrue(success); + Assert.AreEqual(expected, result); + } +} +``` + +## When to suppress warnings + +Do not suppress warnings from this rule. There is no valid scenario where test methods should use `out` or `ref` parameters. + +## Suppress a warning + +If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule. + +```csharp +#pragma warning disable MSTEST0062 +// The code that's violating the rule is on this line. +#pragma warning restore MSTEST0062 +``` + +To disable the rule for a file, folder, or project, set its severity to `none` in the [configuration file](../../../fundamentals/code-analysis/configuration-files.md). + +```ini +[*.{cs,vb}] +dotnet_diagnostic.MSTEST0062.severity = none +``` + +For more information, see [How to suppress code analysis warnings](../../../fundamentals/code-analysis/suppress-warnings.md). diff --git a/docs/core/testing/mstest-analyzers/usage-rules.md b/docs/core/testing/mstest-analyzers/usage-rules.md index 50c3bc7503de9..6a32e92d6215f 100644 --- a/docs/core/testing/mstest-analyzers/usage-rules.md +++ b/docs/core/testing/mstest-analyzers/usage-rules.md @@ -49,3 +49,10 @@ Identifier | Name | Description [MSTEST0053](mstest0053.md) | AvoidAssertFormatParametersAnalyzer | An assertion method call uses the `message` and `parameters` arguments for string formatting instead of using string interpolation. [MSTEST0054](mstest0054.md) | UseCancellationTokenPropertyAnalyzer | Accessing `CancellationToken` via `TestContext.CancellationTokenSource.Token` instead of using the `TestContext.CancellationToken` property. [MSTEST0055](mstest0055.md) | IgnoreStringMethodReturnValueAnalyzer | A call to `string.Contains`, `string.StartsWith`, or `string.EndsWith` is made and its return value is ignored. +[MSTEST0056](mstest0056.md) | TestMethodAttributeShouldSetDisplayNameCorrectlyAnalyzer | A test method attribute uses a string constructor argument instead of the `DisplayName` property. +[MSTEST0057](mstest0057.md) | TestMethodAttributeShouldPropagateSourceInformationAnalyzer | A custom `TestMethodAttribute` class does not propagate caller information to the base class constructor. +[MSTEST0058](mstest0058.md) | AvoidAssertsInCatchBlocksAnalyzer | A test method contains assertion statements within a `catch` block. +[MSTEST0059](mstest0059.md) | UseParallelizeAttributeAnalyzer | An assembly contains both `[Parallelize]` and `[DoNotParallelize]` attributes. +[MSTEST0060](mstest0060.md) | DuplicateTestMethodAttributeAnalyzer | A test method has multiple `TestMethodAttribute` declarations. +[MSTEST0061](mstest0061.md) | UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzer | A test method uses `RuntimeInformation.IsOSPlatform` checks with an early return instead of the `[OSCondition]` attribute. +[MSTEST0062](mstest0062.md) | AvoidOutRefTestMethodParametersAnalyzer | A test method has parameters marked with `out` or `ref` modifiers. diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml index 4c6d64176b43f..5fc6572a57ff8 100644 --- a/docs/navigate/devops-testing/toc.yml +++ b/docs/navigate/devops-testing/toc.yml @@ -237,6 +237,20 @@ items: href: ../../core/testing/mstest-analyzers/mstest0054.md - name: MSTEST0055 href: ../../core/testing/mstest-analyzers/mstest0055.md + - name: MSTEST0056 + href: ../../core/testing/mstest-analyzers/mstest0056.md + - name: MSTEST0057 + href: ../../core/testing/mstest-analyzers/mstest0057.md + - name: MSTEST0058 + href: ../../core/testing/mstest-analyzers/mstest0058.md + - name: MSTEST0059 + href: ../../core/testing/mstest-analyzers/mstest0059.md + - name: MSTEST0060 + href: ../../core/testing/mstest-analyzers/mstest0060.md + - name: MSTEST0061 + href: ../../core/testing/mstest-analyzers/mstest0061.md + - name: MSTEST0062 + href: ../../core/testing/mstest-analyzers/mstest0062.md - name: Test platforms items: - name: Microsoft.Testing.Platform