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/create-unit-tests-menu.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,15 @@
1
1
---
2
2
title: Create unit test method stubs
3
3
description: Learn how to use the Create Unit Tests command, which allows easy configuration of a test project, the test class, and the test method stub within it.
Copy file name to clipboardExpand all lines: docs/test/improve-code-quality.md
+29-8Lines changed: 29 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,18 +41,19 @@ Visual Studio is also extensible and opens the door for third-party unit testing
41
41
> [!NOTE]
42
42
> Live unit testing is available in Enterprise edition only and is only supported for .NET code.
43
43
44
-
## IntelliTest
44
+
::: moniker range="visualstudio"
45
+
## AI tools to generate tests
45
46
46
-
IntelliTest automatically generates unit tests and test data for your managed code. IntelliTest improves coverage and dramatically reduces the effort to create and maintain unit tests for new or existing code.
47
+
Starting in Visual Studio 2026 Insiders build, you can use GitHub Copilot testing for .NET to automatically generate unit tests. GitHub Copilot testing for .NET not only generates the tests, but debugs the tests, and runs them in Test Explorer. For more information, see [Overview of GitHub Copilot testing for .NET](../test/github-copilot-test-dotnet-overview.md). This is the recommended method to generate tests.
47
48
48
-

49
+
Alternatively, you can use Copilot `/tests` slash command to generate unit tests from code. For example, you can type `/tests using NUnit Framework` to generate NUnit tests. For more information, see [Use slash commands in Copilot Chat](../ide/copilot-chat-context.md#slash-commands).
50
+
::: moniker-end
49
51
50
-
> [!NOTE]
51
-
> IntelliTest is available in Enterprise edition only. It is supported for C# code that targets the .NET Framework. .NET Core and .NET Standard are not currently supported.
52
+
::: moniker range="=vs-2022"
53
+
## AI tools to generate tests
52
54
53
-
*[Generate unit tests for your code with IntelliTest](generate-unit-tests-for-your-code-with-intellitest.md)
54
-
*[IntelliTest – One test to rule them all](https://devblogs.microsoft.com/devops/intellitest-one-test-to-rule-them-all/)
You can use Copilot `/tests` slash command to generate unit tests from code. For example, you can type `/tests using NUnit Framework` to generate NUnit tests. For more information, see [Use slash commands in Copilot Chat](../ide/copilot-chat-context.md#slash-commands).
56
+
::: moniker-end
56
57
57
58
## Code coverage
58
59
@@ -90,6 +91,26 @@ Code coverage is an option when you run test methods using Test Explorer. The re
90
91
91
92
::: moniker-end
92
93
94
+
## IntelliTest
95
+
96
+
IntelliTest automatically generates unit tests and test data for your managed code. IntelliTest improves coverage and dramatically reduces the effort to create and maintain unit tests for new or existing code.
97
+
98
+

99
+
100
+
> [!NOTE]
101
+
> IntelliTest is available in Enterprise edition only. It is supported for C# code that targets the .NET Framework. .NET Core and .NET Standard are not supported.
102
+
103
+
*[Generate unit tests for your code with IntelliTest](generate-unit-tests-for-your-code-with-intellitest.md)
104
+
*[IntelliTest – One test to rule them all](https://devblogs.microsoft.com/devops/intellitest-one-test-to-rule-them-all/)
Copy file name to clipboardExpand all lines: docs/test/unit-test-basics.md
+42-19Lines changed: 42 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,12 +18,13 @@ Unit testing has the greatest effect on the quality of your code when it's an in
18
18
19
19
Test Explorer can also run third-party and open source unit test frameworks that have implemented Test Explorer add-on interfaces. You can add many of these frameworks through the Visual Studio Extension Manager and the Visual Studio gallery. For more information, see [Install third-party unit test frameworks](../test/install-third-party-unit-test-frameworks.md).
20
20
21
-
You can quickly generate test projects and test methods from your code, or manually create the tests as you need them. When you use IntelliTest to explore .NET code, you can generate test data and a suite of unit tests. For every statement in the code, a test input is generated that will execute that statement. Find out how to [generate unit tests for .NET code](generate-unit-tests-for-your-code-with-intellitest.md).
22
-
23
21
## Get started
24
22
25
23
For an introduction to unit testing that takes you directly into coding, see one of these articles:
26
24
25
+
::: moniker range="visualstudio"
26
+
-[GitHub Copilot testing for .NET](../test/unit-testing-with-github-copilot-test-dotnet.md)
27
+
::: moniker-end
27
28
-[Walkthrough: Create and run unit tests for .NET code](../test/walkthrough-creating-and-running-unit-tests-for-managed-code.md)
28
29
29
30
-[Walkthrough: Test driven development with Test Explorer](../test/quick-start-test-driven-development-with-test-explorer.md)
@@ -75,9 +76,24 @@ public void Withdraw(double amount)
75
76
76
77
Now that we have some code, it's time for testing.
77
78
79
+
::: moniker range="visualstudio"
80
+
## Create unit tests with Copilot
81
+
82
+
Starting in Visual Studio 2026 Insiders build, you can use GitHub Copilot testing for .NET to automatically generate unit tests. GitHub Copilot testing for .NET not only generates the tests, but debugs the tests, and runs them in Test Explorer. For more information, see [Overview of GitHub Copilot testing for .NET](../test/github-copilot-test-dotnet-overview.md). This is the recommended method to generate tests.
83
+
84
+
Alternatively, you can use Copilot `/tests` slash command to generate unit tests from code. For example, you can type `/tests using NUnit Framework` to generate NUnit tests. For more information, see [Use slash commands in Copilot Chat](../ide/copilot-chat-context.md#slash-commands).
85
+
86
+
### Generate and run unit tests
87
+
88
+
Using the Visual Studio 2026 Insiders build, you can use [GitHub Copilot testing for .NET](../test/unit-testing-with-github-copilot-test-dotnet.md) to automatically generate unit tests.
89
+
90
+
Most of the procedures described in this article apply to manually generated tests. If you want to learn more in-depth information about unit testing, you can read through the rest of this article or skip to the section [Run tests in Test Explorer](#run-tests-in-test-explorer).
91
+
::: moniker-end
92
+
93
+
::: moniker range="vs-2022"
78
94
## Create unit tests with Copilot
79
95
80
-
You can also use Copilot `/tests` slash command to generate unit tests from code. For example, you can type `/tests using NUnit Framework` to generate NUnit tests. For more information, see [Use slash commands in Copilot Chat](../ide/copilot-chat-context.md#slash-commands).
96
+
You can use Copilot `/tests` slash command to generate unit tests from code. For example, you can type `/tests using NUnit Framework` to generate NUnit tests. For more information, see [Use slash commands in Copilot Chat](../ide/copilot-chat-context.md#slash-commands).
81
97
82
98
## Create unit test projects and test methods (C#)
83
99
@@ -87,39 +103,46 @@ For C#, it is often quicker to generate the unit test project and unit test stub
87
103
88
104
1. From the code editor window, right-click and choose [**Create Unit Tests**](create-unit-tests-menu.md) from the right-click menu.
89
105
90
-
::: moniker range="vs-2019"
91
-

106
+

92
107
93
108
> [!NOTE]
94
109
> The **Create Unit Tests** menu command is only available for C# code. To use this method with .NET Core or .NET Standard, Visual Studio 2019 or later is required.
95
-
::: moniker-end
96
110
97
-
::: moniker range=">=vs-2022"
98
-

111
+
2. Select **OK** to accept the defaults to create your unit tests, or change the values used to create and name the unit test project and the unit tests. You can select the code that is added by default to the unit test methods.
112
+
113
+

114
+
115
+
3. The unit test stubs are created in a new unit test project for all the methods in the class.
116
+
117
+

118
+
119
+
4. Now jump ahead to learn how to [Write your tests](#write-your-tests) to make your unit test meaningful, and any extra unit tests that you might want to add to thoroughly test your code.
120
+
::: moniker-end
121
+
122
+
::: moniker range="<= vs-2019"
123
+
## Create unit test projects and test methods (C#)
124
+
125
+
For C#, it is often quicker to generate the unit test project and unit test stubs from your code. Or you can choose to create the unit test project and tests manually depending on your requirements. If you want to create unit tests from code with a 3rd party framework you will need one of these extensions installed: [NUnit](https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.TestGeneratorNUnitextension-18371) or [xUnit](https://marketplace.visualstudio.com/items?itemName=YowkoTsai.xUnitnetTestGenerator). If you are not using C#, skip this section and go to [Create the unit test project and unit tests manually](#create-the-unit-test-project-and-unit-tests-manually).
126
+
127
+
### Generate unit test project and unit test stubs
128
+
129
+
1. From the code editor window, right-click and choose [**Create Unit Tests**](create-unit-tests-menu.md) from the right-click menu.
130
+
131
+

99
132
100
133
> [!NOTE]
101
134
> The **Create Unit Tests** menu command is only available for C# code. To use this method with .NET Core or .NET Standard, Visual Studio 2019 or later is required.
102
-
::: moniker-end
103
135
104
136
2. Select **OK** to accept the defaults to create your unit tests, or change the values used to create and name the unit test project and the unit tests. You can select the code that is added by default to the unit test methods.
105
137
106
-
::: moniker range="<=vs-2019"
107
138

108
-
::: moniker-end
109
-
::: moniker range=">=vs-2022"
110
-

111
-
::: moniker-end
112
139
113
140
3. The unit test stubs are created in a new unit test project for all the methods in the class.
114
141
115
-
::: moniker range="vs-2019"
116
142

117
-
::: moniker-end
118
-
::: moniker range=">=vs-2022"
119
-

120
-
::: moniker-end
121
143
122
144
4. Now jump ahead to learn how to [Write your tests](#write-your-tests) to make your unit test meaningful, and any extra unit tests that you might want to add to thoroughly test your code.
145
+
::: moniker-end
123
146
124
147
### Create the unit test project and unit tests manually
Copy file name to clipboardExpand all lines: docs/test/unit-test-your-code.md
+8-1Lines changed: 8 additions & 1 deletion
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: Explore unit test tools and tasks
3
3
description: Learn about the unit test tools you can use to give developers and testers a quick way to look for logic errors in your code.
4
-
ms.date: 12/05/2023
4
+
ms.date: 11/25/2025
5
5
ms.topic: article
6
6
helpviewer_keywords:
7
7
- Visual Studio, unit tests
@@ -28,7 +28,14 @@ The unit test tools include:
28
28
29
29
***Microsoft Fakes isolation framework**—The Microsoft Fakes isolation framework can create substitute classes and methods for production and system .NET code that create dependencies in the code under test. By implementing the fake delegates for a function, you control the behavior and output of the dependency object.
30
30
31
+
::: moniker range="visualstudio"
32
+
Starting in Visual Studio 2026 Insiders build, you can use GitHub Copilot testing for .NET to automatically generate unit tests. GitHub Copilot testing for .NET not only generates the tests, but debugs the tests, and runs them in Test Explorer. For more information, see [Overview of GitHub Copilot testing for .NET](../test/github-copilot-test-dotnet-overview.md). This is the recommended method to generate tests.
33
+
34
+
Alternatively, you can use Copilot `/tests` slash command to generate unit tests from code. For example, you can type `/tests using NUnit Framework` to generate NUnit tests. For more information, see [Use slash commands in Copilot Chat](../ide/copilot-chat-context.md#slash-commands).
35
+
::: moniker-end
36
+
::: moniker range="<= vs-2022"
31
37
For .NET, you can also use [IntelliTest](../test/generate-unit-tests-for-your-code-with-intellitest.md) to explore your code and generate test data and a suite of unit tests. For every statement in the code, a test input is generated that will execute that statement. A case analysis is performed for every conditional branch in the code.
Copy file name to clipboardExpand all lines: docs/test/walkthrough-creating-and-running-unit-tests-for-managed-code.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,14 @@ This article steps you through creating, running, and customizing a series of un
21
21
22
22
This article describes how to manually create unit tests. If you would like to generate tests automatically from existing code, see the following articles:
23
23
24
+
::: moniker range="visualstudio"
25
+
-[Generate and run unit tests using GitHub Copilot testing for .NET](../test/unit-testing-with-github-copilot-test-dotnet.md)
26
+
-[Use slash commands in GitHub Copilot](../ide/copilot-chat-context.md#slash-commands)
27
+
::: moniker-end
28
+
::: moniker range="<= vs-2022"
24
29
-[Create unit test method stubs from code](../test/create-unit-tests-menu.md)
25
30
-[Use slash commands in GitHub Copilot](../ide/copilot-chat-context.md#slash-commands)
0 commit comments