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/test/quick-start-test-driven-development-with-test-explorer.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Test-driven development walkthrough
3
3
description: Learn how to develop a tested method in C# using Microsoft Test Framework, which you can easily adapt for other languages or test frameworks, such as NUnit.
4
-
ms.date: 12/04/2023
4
+
ms.date: 5/16/2025
5
5
ms.topic: conceptual
6
6
ms.author: mikejo
7
7
manager: mijacobs
@@ -18,7 +18,7 @@ This walkthrough demonstrates how to develop a tested method in C# using Microso
18
18
19
19
1. Create a C# **Class Library** project for .NET or .NET Standard. This project will contain the code that we want to test. Name the project **MyMath**.
20
20
21
-
2. In the same solution, add a new MSTest test project for .NET.
21
+
2. In the same solution, add a new **MSTest** test project for .NET.
22
22
23
23
In Visual Studio 2019 version 16.9, the MSTest project template name is **Unit Test Project**.
24
24
@@ -31,7 +31,7 @@ This walkthrough demonstrates how to develop a tested method in C# using Microso
31
31

32
32
::: moniker-end
33
33
34
-
3.Write a simple test method that verifies the result obtained for a specific input. Add the following code to the `UnitTest1` class:
34
+
3.In the test project, write a simple test method that verifies the result obtained for a specific input. Add the following code to the`Test1` or`UnitTest1` class:
35
35
36
36
```csharp
37
37
[TestMethod]
@@ -51,12 +51,16 @@ This walkthrough demonstrates how to develop a tested method in C# using Microso
51
51
52
52
4. Generate a type from the test code.
53
53
54
-
1. Place the cursor on `Rooter`, and then from the light bulb menu, choose **Generate type 'Rooter'** > **Generate new type**.
54
+
1. Place the cursor on `Rooter`, and then open the light bulb menu.
55
55
56
56
::: moniker range=">=vs-2022"
57
+
Choose **Generate new type**.
58
+
57
59

58
60
::: moniker-end
59
61
::: moniker range="vs-2019"
62
+
Choose **Generate type 'Rooter'** > **Generate new type**.
63
+
60
64

61
65
::: moniker-end
62
66
@@ -69,7 +73,7 @@ This walkthrough demonstrates how to develop a tested method in C# using Microso
69
73

70
74
::: moniker-end
71
75
72
-
5. Generate a method from the test code. Place the cursor on `SquareRoot`, and then from the light bulb menu, choose **Generate method 'Rooter.SquareRoot'**.
76
+
5. Generate a method from the test code. Place the cursor on `SquareRoot`, and then from the light bulb menu, choose **Generate method 'SquareRoot'** or **Generate method 'Rooter.SquareRoot'**.
73
77
74
78
6. Run the unit test.
75
79
@@ -78,7 +82,7 @@ This walkthrough demonstrates how to develop a tested method in C# using Microso
78
82
::: moniker range=">=vs-2022"
79
83
To open Test Explorer from the **Test** menu, choose **Test Explorer**.
80
84
::: moniker-end
81
-
::: moniker range=">=vs-2022"
85
+
::: moniker range="vs-2019"
82
86
To open Test Explorer from the **Test** menu, choose **Windows** > **Test Explorer**.
83
87
::: moniker-end
84
88
@@ -193,11 +197,9 @@ To improve our confidence that the code works in all cases, add tests that try a
0 commit comments