Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/core/testing/mstest-analyzers/mstest0011.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Methods marked with `[ClassCleanup]` should follow the following layout to be va
- it should not be `async void`
- it should not be a special method (finalizer, operator...).
- it should not be generic
- it should not take any parameter
- it should not take any parameter, or starting with MSTest 3.8, it can have a single `TestContext` parameter
- return type should be `void`, `Task` or `ValueTask`
- `InheritanceBehavior.BeforeEachDerivedClass` attribute parameter should be specified if the class is `abstract`.
- `InheritanceBehavior.BeforeEachDerivedClass` attribute parameter should not be specified if the class is `sealed`.
Expand Down
2 changes: 1 addition & 1 deletion docs/core/testing/mstest-analyzers/mstest0013.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Methods marked with `[AssemblyCleanup]` should follow the following layout to be
- it should not be `async void`
- it should not be a special method (finalizer, operator...).
- it should not be generic
- it should not take any parameter
- it should not take any parameter, or starting with MSTest 3.8, it can have a single `TestContext` parameter
- return type should be `void`, `Task` or `ValueTask`

The type declaring these methods should also respect the following rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Setup and cleanup that is common to multiple tests can be extracted to a separat

[AssemblyInitialize](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyInitializeAttribute>) is called right after your assembly is loaded and [AssemblyCleanup](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyCleanupAttribute>) is called right before your assembly is unloaded.

The methods marked with these attributes should be defined as `static void`, `static Task` or `static ValueTask` (starting with MSTest v3.3), in a `TestClass`, and appear only once. The initialize part requires one argument of type [TestContext](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext) and the cleanup no argument.
The methods marked with these attributes should be defined as `static void`, `static Task` or `static ValueTask` (starting with MSTest v3.3), in a `TestClass`, and appear only once. The initialize part requires one parameter of type [TestContext](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext) and the cleanup either no parameters, or starting with MSTest 3.8 can have one parameter of type [TestContext](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext).

```csharp
[TestClass]
Expand All @@ -201,7 +201,7 @@ public class MyTestClass
}

[AssemblyCleanup]
public static void AssemblyCleanup()
public static void AssemblyCleanup() // Starting with MSTest 3.8, it can be AssemblyCleanup(TestContext testContext)
{
}
}
Expand All @@ -217,7 +217,7 @@ public class MyOtherTestClass
}

[AssemblyCleanup]
public static async Task AssemblyCleanup()
public static async Task AssemblyCleanup() // Starting with MSTest 3.8, it can be AssemblyCleanup(TestContext testContext)
{
}
}
Expand All @@ -231,7 +231,7 @@ It's possible to control the inheritance behavior: only for current class using

It's also possible to configure whether the class cleanup should be run at the end of the class or at the end of the assembly.

The methods marked with these attributes should be defined as `static void`, `static Task` or `static ValueTask` (starting with MSTest v3.3), in a `TestClass`, and appear only once. The initialize part requires one argument of type [TestContext](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext) and the cleanup no argument.
The methods marked with these attributes should be defined as `static void`, `static Task` or `static ValueTask` (starting with MSTest v3.3), in a `TestClass`, and appear only once. The initialize part requires one parameter of type [TestContext](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext) and the cleanup either no parameters, or starting with MSTest 3.8 can have one parameter of type [TestContext](xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext).

```csharp
[TestClass]
Expand All @@ -243,7 +243,7 @@ public class MyTestClass
}

[ClassCleanup]
public static void ClassCleanup()
public static void ClassCleanup() // Starting with MSTest 3.8, it can be ClassCleanup(TestContext testContext)
{
}
}
Expand All @@ -259,7 +259,7 @@ public class MyOtherTestClass
}

[ClassCleanup]
public static async Task ClassCleanup()
public static async Task ClassCleanup() // Starting with MSTest 3.8, it can be ClassCleanup(TestContext testContext)
{
}
}
Expand Down
Loading