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
Copy file name to clipboardExpand all lines: docs/core/testing/unit-testing-mstest-writing-tests-attributes.md
+5-21Lines changed: 5 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,7 +189,7 @@ Setup and cleanup that is common to multiple tests can be extracted to a separat
189
189
190
190
[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.
191
191
192
-
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.
192
+
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).
publicstaticvoidAssemblyCleanup() // Starting with MSTest 3.8, it can be AssemblyCleanup(TestContext testContext)
221
205
{
222
206
}
223
207
}
@@ -231,7 +215,7 @@ It's possible to control the inheritance behavior: only for current class using
231
215
232
216
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.
233
217
234
-
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.
218
+
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).
235
219
236
220
```csharp
237
221
[TestClass]
@@ -243,7 +227,7 @@ public class MyTestClass
243
227
}
244
228
245
229
[ClassCleanup]
246
-
publicstaticvoidClassCleanup()
230
+
publicstaticvoidClassCleanup()// Starting with MSTest 3.8, it can be ClassCleanup(TestContext testContext)
247
231
{
248
232
}
249
233
}
@@ -259,7 +243,7 @@ public class MyOtherTestClass
259
243
}
260
244
261
245
[ClassCleanup]
262
-
publicstaticasyncTaskClassCleanup()
246
+
publicstaticasyncTaskClassCleanup()// Starting with MSTest 3.8, it can be ClassCleanup(TestContext testContext)
0 commit comments