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-migration-from-v1-to-v3.md
+3-31Lines changed: 3 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,7 @@ Choose the option that best suits your project setup. Both methods ensure your p
97
97
98
98
- **Replace Deprecated Methods**: Update deprecated methods to newer versions.
99
99
100
-
- **Assert.AreEqual/AreNotEqual (with object)** → Use generic versions.
100
+
- **Assert.AreEqual/AreNotEqual or Assert.AreSame/AreNotSame (with object)** → Use generic versions.
101
101
102
102
- **Before** (deprecated):
103
103
@@ -131,7 +131,7 @@ Choose the option that best suits your project setup. Both methods ensure your p
131
131
132
132
- **Test Initialization**: Use `TestInitialize` methods for async initialization.
133
133
- **Cleanup**: Use `TestCleanup` methods or the `Dispose` pattern for cleanup.
134
-
- **RunSettings**: The `.testsettings` file is no longer supported, meaning `<LegacySettings>` is also no longer available. Use [.runsettings](https://learn.microsoft.com/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file) fortest configuration.
134
+
- **RunSettings**: The `.testsettings` file is no longer supported, meaning `<LegacySettings>` is also no longer available. Use [.runsettings](/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file) fortest configuration.
135
135
136
136
---
137
137
@@ -171,7 +171,7 @@ MSTest v3 removes certain `Assert` overloads that accept object types to promote
171
171
Assert.AreEqual(expected, actual); // both are objects
172
172
173
173
// New (v3)
174
-
Assert.AreEqual<int>(expectedInt, actualInt); // specify the type
174
+
Assert.AreEqual<object>(expectedInt, actualInt); // specify the type
175
175
```
176
176
177
177
### DataRowAttribute Updates
@@ -258,34 +258,6 @@ MSTest v3 includes built-in code analyzers for best practices, avoiding configur
258
258
259
259
---
260
260
261
-
## Sample Code: Migration Example
262
-
263
-
### Before (MSTest v1)
264
-
265
-
```csharp
266
-
[TestMethod]
267
-
[Timeout(1000)]
268
-
[DataRow(1, "data")]
269
-
public void ExampleTestMethod(int number, string data)
270
-
{
271
-
Assert.AreEqual(number, Convert.ToInt32(data));
272
-
}
273
-
```
274
-
275
-
### After (MSTest v3)
276
-
277
-
```csharp
278
-
[TestMethod]
279
-
[Timeout(1000)]
280
-
[DataRow(1, "data")]
281
-
public void ExampleTestMethod(int number, string data)
0 commit comments