From e6e3678dff32ca5a7ad533b47dcebe62753ba419 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 15 Jan 2025 22:10:42 +0100 Subject: [PATCH 1/2] Update MSTest analyzer docs --- docs/core/testing/mstest-analyzers/design-rules.md | 2 ++ docs/core/testing/mstest-analyzers/mstest0034.md | 2 +- docs/core/testing/mstest-analyzers/mstest0035.md | 2 +- docs/core/testing/mstest-analyzers/mstest0036.md | 2 +- docs/core/testing/mstest-analyzers/mstest0038.md | 2 +- docs/core/testing/mstest-analyzers/usage-rules.md | 6 ++++++ docs/navigate/devops-testing/toc.yml | 2 ++ 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/core/testing/mstest-analyzers/design-rules.md b/docs/core/testing/mstest-analyzers/design-rules.md index f24d93893c379..9131d6679c5d5 100644 --- a/docs/core/testing/mstest-analyzers/design-rules.md +++ b/docs/core/testing/mstest-analyzers/design-rules.md @@ -21,3 +21,5 @@ Identifier | Name | Description [MSTEST0021](mstest0021.md) | PreferDisposeOverTestCleanupAnalyzer | Prefer Dispose over TestCleanup methods [MSTEST0022](mstest0022.md) | PreferTestCleanupOverDisposeAnalyzer | Prefer TestCleanup over Dispose methods [MSTEST0025](mstest0025.md) | PreferAssertFailOverAlwaysFalseConditionsAnalyzer | Use 'Assert.Fail' instead of an always-failing assert +[MSTEST0029](mstest0029.md) | PublicMethodShouldBeTestMethod | A `public` method of a class marked with `[TestClass]` should be a test method (marked with `[TestMethod]`). The rule ignores methods that are marked with `[TestInitialize]`, or `[TestCleanup]` attributes. +[MSTEST0036](mstest0036.md) | DoNotUseShadowingAnalyzer | Shadowing test members could cause testing issues (such as NRE). \ No newline at end of file diff --git a/docs/core/testing/mstest-analyzers/mstest0034.md b/docs/core/testing/mstest-analyzers/mstest0034.md index fa792a2ab74e4..d2af3c4dbbde0 100644 --- a/docs/core/testing/mstest-analyzers/mstest0034.md +++ b/docs/core/testing/mstest-analyzers/mstest0034.md @@ -11,7 +11,7 @@ helpviewer_keywords: author: engyebrahim ms.author: enjieid --- -# MSTEST0034: Use `ClassCleanupBehavior.EndOfClass` with the `[ClassCleanup]`. +# MSTEST0034: Use `ClassCleanupBehavior.EndOfClass` with the `[ClassCleanup]` | Property | Value | |-------------------------------------|------------------------------------------------------------------| diff --git a/docs/core/testing/mstest-analyzers/mstest0035.md b/docs/core/testing/mstest-analyzers/mstest0035.md index d045d80776201..fc88e19ba0524 100644 --- a/docs/core/testing/mstest-analyzers/mstest0035.md +++ b/docs/core/testing/mstest-analyzers/mstest0035.md @@ -11,7 +11,7 @@ helpviewer_keywords: author: engyebrahim ms.author: enjieid --- -# MSTEST0035: `[DeploymentItem]` can be specified only on test class or test method. +# MSTEST0035: `[DeploymentItem]` can be specified only on test class or test method | Property | Value | |-------------------------------------|------------------------------------------------------------------------| diff --git a/docs/core/testing/mstest-analyzers/mstest0036.md b/docs/core/testing/mstest-analyzers/mstest0036.md index 86e4081ba4a77..e0a055466bc7e 100644 --- a/docs/core/testing/mstest-analyzers/mstest0036.md +++ b/docs/core/testing/mstest-analyzers/mstest0036.md @@ -11,7 +11,7 @@ helpviewer_keywords: author: engyebrahim ms.author: enjieid --- -# MSTEST0036: Do not use shadowing inside test class. +# MSTEST0036: Do not use shadowing inside test class | Property | Value | |-------------------------------------|------------------------------------------------------------------------| diff --git a/docs/core/testing/mstest-analyzers/mstest0038.md b/docs/core/testing/mstest-analyzers/mstest0038.md index 41240248c0223..09423518792da 100644 --- a/docs/core/testing/mstest-analyzers/mstest0038.md +++ b/docs/core/testing/mstest-analyzers/mstest0038.md @@ -22,7 +22,7 @@ ms.author: ygerges | **Enabled by default** | Yes | | **Default severity** | Warning | | **Introduced in version** | 3.8.0 | -| **Is there a code fix** | No | +| **Is there a code fix** | Yes | ## Cause diff --git a/docs/core/testing/mstest-analyzers/usage-rules.md b/docs/core/testing/mstest-analyzers/usage-rules.md index dafef4793f875..cbd2bdfa23b9a 100644 --- a/docs/core/testing/mstest-analyzers/usage-rules.md +++ b/docs/core/testing/mstest-analyzers/usage-rules.md @@ -24,8 +24,14 @@ Identifier | Name | Description [MSTEST0013](mstest0013.md) | AssemblyCleanupShouldBeValidAnalyzer | Methods marked with `[AssemblyCleanup]` should follow the following layout to be valid:
- it should be `public`
- it should be `static`
- it should not be generic
- it should not take any parameter
- return type should be `void`, `Task` or `ValueTask`
- it should not be `async void`
- it should not be a special method (finalizer, operator...). [MSTEST0014](mstest0014.md) | DataRowShouldBeValidAnalyzer | `[DataRow]` instances should have the following layout to be valid:
- they should only be set on a test method
- argument count should match method parameters count
- argument type should match method argument type [MSTEST0017](mstest0017.md) | AssertionArgsShouldBePassedInCorrectOrder | Assertion arguments should be passed in the correct order +[MSTEST0018](mstest0018.md) | DynamicDataShouldBeValidAnalyzer | Methods marked with `[DynamicData]` should also be marked with `[TestMethod]` (or a derived attribute) [MSTEST0023](mstest0023.md) | DoNotNegateBooleanAssertionAnalyzer | Do not negate boolean assertions [MSTEST0024](mstest0024.md) | DoNotStoreStaticTestContextAnalyzer | Do not store TestContext in a static member [MSTEST0026](mstest0026.md) | AssertionArgsShouldAvoidConditionalAccessRuleId | Avoid conditional access in assertions +[MSTEST0030](mstest0030.md) | TypeContainingTestMethodShouldBeATestClass | Type containing `[TestMethod]` should be marked with `[TestClass]` +[MSTEST0031](mstest0031.md) | DoNotUseSystemDescriptionAttribute | 'System.ComponentModel.DescriptionAttribute' has no effect in the context of tests +[MSTEST0032](mstest0032.md) | ReviewAlwaysTrueAssertConditionAnalyzer | Review or remove the assertion as its condition is known to be always true +[MSTEST0034](mstest0034.md) | UseClassCleanupBehaviorEndOfClass | Use `ClassCleanupBehavior.EndOfClass` with the `[ClassCleanup]` +[MSTEST0035](mstest0035.md) | UseDeploymentItemWithTestMethodOrTestClassTitle | `[DeploymentItem]` can be specified only on test class or test method [MSTEST0037](mstest0037.md) | UseProperAssertMethodsAnalyzer | Use proper `Assert` methods [MSTEST0038](mstest0038.md) | AvoidAssertAreSameWithValueTypesAnalyzer | Don't use `Assert.AreSame` or `Assert.AreNotSame` with value types diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml index fd3d693eb78f5..4a64586b2510c 100644 --- a/docs/navigate/devops-testing/toc.yml +++ b/docs/navigate/devops-testing/toc.yml @@ -191,6 +191,8 @@ items: href: ../../core/testing/mstest-analyzers/mstest0035.md - name: MSTEST0037 href: ../../core/testing/mstest-analyzers/mstest0037.md + - name: MSTEST0038 + href: ../../core/testing/mstest-analyzers/mstest0038.md - name: Microsoft Testing Platform items: - name: Overview From 5e95fc165b1967db6def3fcfa291ce27f485069d Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Wed, 15 Jan 2025 22:17:22 +0100 Subject: [PATCH 2/2] Fix markdownlint violation --- docs/core/testing/mstest-analyzers/design-rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/testing/mstest-analyzers/design-rules.md b/docs/core/testing/mstest-analyzers/design-rules.md index 9131d6679c5d5..17c11c9f96027 100644 --- a/docs/core/testing/mstest-analyzers/design-rules.md +++ b/docs/core/testing/mstest-analyzers/design-rules.md @@ -22,4 +22,4 @@ Identifier | Name | Description [MSTEST0022](mstest0022.md) | PreferTestCleanupOverDisposeAnalyzer | Prefer TestCleanup over Dispose methods [MSTEST0025](mstest0025.md) | PreferAssertFailOverAlwaysFalseConditionsAnalyzer | Use 'Assert.Fail' instead of an always-failing assert [MSTEST0029](mstest0029.md) | PublicMethodShouldBeTestMethod | A `public` method of a class marked with `[TestClass]` should be a test method (marked with `[TestMethod]`). The rule ignores methods that are marked with `[TestInitialize]`, or `[TestCleanup]` attributes. -[MSTEST0036](mstest0036.md) | DoNotUseShadowingAnalyzer | Shadowing test members could cause testing issues (such as NRE). \ No newline at end of file +[MSTEST0036](mstest0036.md) | DoNotUseShadowingAnalyzer | Shadowing test members could cause testing issues (such as NRE).