Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ The `Workers` property specifies the maximum number of threads for parallel exec

The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DoNotParallelizeAttribute> prevents parallel execution for specific assemblies, classes, or methods. Use this attribute when tests share state or resources that can't be safely accessed concurrently.

When you enable in-assembly parallelization, MSTest partitions each test source (assembly) into parallelizable and nonparallelizable tests. MSTest runs the parallelizable set first, then runs the `DoNotParallelize` set one test at a time at the end of that source's run. In runs that include multiple test sources, each source has its own deferred tail. Because deferred tests can't overlap with other tests, a slow deferred test usually increases total run time by about its own duration.

Because MSTest runs deferred tests only after the parallelizable phase finishes, a canceled or aborted run can end before MSTest executes deferred tests. The execution order described here is an internal implementation detail and isn't a public contract. It might change in a future version of MSTest.

```csharp
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]

Expand Down Expand Up @@ -195,7 +199,7 @@ public class MixedTests
```

> [!NOTE]
> You only need `DoNotParallelize` when you've enabled parallel execution with the `Parallelize` attribute.
> You only need `DoNotParallelize` when you've enabled parallel execution with the `Parallelize` attribute. When parallelization is disabled (the default), `DoNotParallelize` has no effect.

### `ResourceLockAttribute`

Expand Down
Loading