Skip to content

Commit f7d4f67

Browse files
authored
Update unit-testing-mstest-migration-from-v1-to-v3.md
1 parent acb6c77 commit f7d4f67

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

docs/core/testing/unit-testing-mstest-migration-from-v1-to-v3.md

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Choose the option that best suits your project setup. Both methods ensure your p
9797

9898
- **Replace Deprecated Methods**: Update deprecated methods to newer versions.
9999

100-
- **Assert.AreEqual/AreNotEqual (with object)** → Use generic versions.
100+
- **Assert.AreEqual/AreNotEqual or Assert.AreSame/AreNotSame (with object)** → Use generic versions.
101101

102102
- **Before** (deprecated):
103103

@@ -131,7 +131,7 @@ Choose the option that best suits your project setup. Both methods ensure your p
131131

132132
- **Test Initialization**: Use `TestInitialize` methods for async initialization.
133133
- **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) for test 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) for test configuration.
135135

136136
---
137137

@@ -171,7 +171,7 @@ MSTest v3 removes certain `Assert` overloads that accept object types to promote
171171
Assert.AreEqual(expected, actual); // both are objects
172172
173173
// New (v3)
174-
Assert.AreEqual<int>(expectedInt, actualInt); // specify the type
174+
Assert.AreEqual<object>(expectedInt, actualInt); // specify the type
175175
```
176176

177177
### DataRowAttribute Updates
@@ -258,34 +258,6 @@ MSTest v3 includes built-in code analyzers for best practices, avoiding configur
258258
259259
---
260260
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)
282-
{
283-
Assert.AreEqual<int>(number, Convert.ToInt32(data));
284-
}
285-
```
286-
287-
---
288-
289261
## Additional Resources
290262
291263
- [New testing platform](unit-testing-platform-intro.md)

0 commit comments

Comments
 (0)