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
+6-6Lines changed: 6 additions & 6 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).
193
193
194
194
```csharp
195
195
[TestClass]
@@ -201,7 +201,7 @@ public class MyTestClass
201
201
}
202
202
203
203
[AssemblyCleanup]
204
-
publicstaticvoidAssemblyCleanup()
204
+
publicstaticvoidAssemblyCleanup()// Starting with MSTest 3.8, it can be AssemblyCleanup(TestContext testContext)
205
205
{
206
206
}
207
207
}
@@ -217,7 +217,7 @@ public class MyOtherTestClass
217
217
}
218
218
219
219
[AssemblyCleanup]
220
-
publicstaticasyncTaskAssemblyCleanup()
220
+
publicstaticasyncTaskAssemblyCleanup()// Starting with MSTest 3.8, it can be AssemblyCleanup(TestContext testContext)
221
221
{
222
222
}
223
223
}
@@ -231,7 +231,7 @@ It's possible to control the inheritance behavior: only for current class using
231
231
232
232
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
233
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.
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 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
235
236
236
```csharp
237
237
[TestClass]
@@ -243,7 +243,7 @@ public class MyTestClass
243
243
}
244
244
245
245
[ClassCleanup]
246
-
publicstaticvoidClassCleanup()
246
+
publicstaticvoidClassCleanup()// Starting with MSTest 3.8, it can be ClassCleanup(TestContext testContext)
247
247
{
248
248
}
249
249
}
@@ -259,7 +259,7 @@ public class MyOtherTestClass
259
259
}
260
260
261
261
[ClassCleanup]
262
-
publicstaticasyncTaskClassCleanup()
262
+
publicstaticasyncTaskClassCleanup()// Starting with MSTest 3.8, it can be ClassCleanup(TestContext testContext)
0 commit comments