You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1561,6 +1562,10 @@ For more information, see [MSTest runner profile](../testing/unit-testing-mstest
1561
1562
1562
1563
Set the `UseVSTest` property to `true` to switch from the MSTest runner to the [VSTest](/visualstudio/test/vstest-console-options) runner when using the [MSTest project SDK](../testing/unit-testing-mstest-sdk.md).
1563
1564
1565
+
### MSTestAnalysisMode
1566
+
1567
+
This property decides which analyzers are enabled at which severity. For more information, see [MSTest code analysis](../testing/mstest-analyzers/overview.md).
1568
+
1564
1569
## Hosting-related properties
1565
1570
1566
1571
The following MSBuild properties are documented in this section:
> This rule is opt-in. It's not enabled even when using `<MSTestAnalysisMode>All</MSTestAnalysisMode>`. For more information about `MSTestAnalysisMode`, see [MSTest code analysis](../overview.md).
Copy file name to clipboardExpand all lines: docs/core/testing/mstest-analyzers/overview.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,55 @@ ms.date: 12/20/2023
15
15
16
16
The rules are organized into categories such as performance usage...
17
17
18
+
Starting with MSTest.TestFramework 3.7, the MSTest.Analyzers NuGet package is a dependency of the framework. For earlier versions, you need to use `MSTest` metapackage or add a package reference for `MSTest.Analyzers` explicitly.
19
+
20
+
## MSTestAnalysisMode
21
+
22
+
Starting with MSTest 3.8, an MSBuild property named `MSTestAnalysisMode` is available to determine which analyzers are enabled at which severity.
23
+
24
+
> [!TIP]
25
+
> To see which rules are enabled at which severity for each mode, you can navigate to the package of the version of interest in NuGet cache, locate the `globalconfigs` directory, and open the `.globalconfig` file corresponding to the analysis mode.
26
+
> For more information on finding the NuGet cache directory, see [Managing the global packages, cache, and temp folders](/nuget/consume-packages/managing-the-global-packages-and-cache-folders). From that directory, locate `mstest.analyzers` directory, then the version (3.8 and higher), then `globalconfigs`.
27
+
> Alternatively, you can download the NuGet package of the version of interest from `nuget.org` and view it in NuGet Package Explorer (Windows app), or view directly in the [web app version of NuGet Package Explorer](https://nuget.info/packages/MSTest.Analyzers/).
28
+
29
+
The available values for this property:
30
+
31
+
-[`None`](#none)
32
+
-[`Default`](#default)
33
+
-[`Recommended`](#recommended)
34
+
-[`All`](#all)
35
+
36
+
### `None`
37
+
38
+
This value sets all analyzers to `none` severity, disabling all of them. You can then enable individual analyzers using `.editorconfig` or `.globalconfig` files.
39
+
40
+
### `Default`
41
+
42
+
This setting follows the default documented behavior for each rule.
43
+
44
+
- Rules that are enabled by default will use their default severity.
45
+
- Rules that are disabled by default will use `none` severity.
46
+
47
+
> [!NOTE]
48
+
> Rules that are enabled by default as warnings are violations that are expected to cause issues at run time.
49
+
50
+
### `Recommended`
51
+
52
+
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.
53
+
54
+
### `All`
55
+
56
+
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.
57
+
58
+
> [!NOTE]
59
+
> The following rules are completely opt-in and are not enabled in `Default`, `Recommended`, or `All` modes:
60
+
>
61
+
> -[MSTEST0015: Test method should not be ignored](mstest0015.md)
62
+
> -[MSTEST0019: Prefer TestInitialize methods over constructors](mstest0019.md)
63
+
> -[MSTEST0020: Prefer constructors over TestInitialize methods](mstest0020.md)
64
+
> -[MSTEST0021: Prefer Dispose over TestCleanup methods](mstest0021.md)
65
+
> -[MSTEST0022: Prefer TestCleanup over Dispose methods](mstest0022.md)
0 commit comments