Skip to content

Commit

Permalink
Add MSTest analyzers documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Dec 20, 2023
1 parent 5e3a054 commit 17b6f83
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/core/testing/unit-testing-mstest-analyzers-MSTEST0001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "MSTEST0001: Explicitly enable or disable tests parallelization"
description: "Learn about code analysis rule MSTEST0001: Explicitly enable or disable tests parallelization"
ms.date: 12/20/2023
f1_keywords:
- MSTEST0001
- UseParallelizeAttributeAnalyzer
helpviewer_keywords:
- UseParallelizeAttributeAnalyzer
- MSTEST0001
author: evangelink
ms.author: amauryleve
dev_langs:
- CSharp
- VB
---
# MSTEST0001: Explicitly enable or disable tests parallelization

| Property | Value |
|-------------------------------------|----------------------------------------------------|
| **Rule ID** | MSTEST0001 |
| **Title** | Explicitly enable or disable tests parallelization |
| **Category** | Performance |
| **Fix is breaking or non-breaking** | Non-breaking |
| **Enabled by default** | Yes |
| **Default severity** | Warning |

## Cause

The assembly is not marked with `[Parallelize]` or `[DoNotParallelize]` attribute.

## Rule description

By default, MSTest runs tests sequentially which can lead to severe performance limitations. It is recommended to enable assembly attribute `[Parallelize]` or if the assembly is known to not be parallelizable, to use explicitly the assembly level attribute `[DoNotParallelize]`.

## How to fix violations

To fix a violation of this rule, add `[assembly: Parallelize]` or `[assembly: DoNotParallelize]` attribute.

## When to suppress warnings

Do not suppress a warning from this rule. Many libraries can benefit from a massive performance boost when enabling parallelization. When the test application is designed in a way that prevents parallelization, having the attribute explicitly set helps new developers to understand the limitations of the library.
15 changes: 15 additions & 0 deletions docs/core/testing/unit-testing-mstest-analyzers-performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Performance rules (code analysis)
description: Learn about code analysis performance rules.
author: evangelink
ms.author: amauryleve
ms.date: 12/20/2023
---

# Performance rules

Rules that support high-performance testing.

Identifier | Name | Description
-----------|------|------------
[MSTEST0001](unit-testing-mstest-analyzers-MSTEST0001.md) | UseParallelizeAttributeAnalyzer | By default, MSTest runs tests sequentially which can lead to severe performance limitations. It is recommended to enable assembly attribute `[Parallelize]` or if the assembly is known to not be parallelizable, to use explicitly the assembly level attribute `[DoNotParallelize]`.
22 changes: 22 additions & 0 deletions docs/core/testing/unit-testing-mstest-analyzers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: MSTest code analysis
description: Learn about the MSTest code analysis.
author: evangelink
ms.author: amauryleve
ms.date: 12/20/2023
---

# MSTest code analysis

*MSTest analysis* ("MSTESTxxxx") rules inspect your C# or Visual Basic code for security, performance, design and other issues.

> [!TIP]
> If you're using Visual Studio, many analyzer rules have associated *code fixes* that you can apply to correct the problem. Code fixes are shown in the light bulb icon menu.
The rules are organized into categories such as performance usage...

## Categories

**[Performance rules](unit-testing-mstest-analyzers-performance.md)**

Rules that support high-performance testing.
10 changes: 10 additions & 0 deletions docs/navigate/devops-testing/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ items:
href: ../../core/testing/unit-testing-mstest-runner-telemetry.md
- name: Known exit codes
href: ../../core/testing/unit-testing-mstest-runner-exit-codes.md
- name: Code analysis
items:
- name: Overview
href: ../../core/testing/unit-testing-mstest-analyzers.md
- name: Performance
items:
- name: Overview
href: ../../core/testing/unit-testing-mstest-analyzers-performance.md
- name: MSTEST0001
href: ../../core/testing/unit-testing-mstest-analyzers-MSTEST0001.md
- name: Run selective unit tests
href: ../../core/testing/selective-unit-tests.md
- name: Order unit tests
Expand Down

0 comments on commit 17b6f83

Please sign in to comment.