Skip to content

Commit 92f6ec3

Browse files
Merge pull request #14690 from Mikejo5000/mikejo-br26
Update versioning related to create unit tests command
2 parents 34fd609 + c5108aa commit 92f6ec3

6 files changed

Lines changed: 89 additions & 33 deletions

docs/test/create-unit-tests-menu.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
22
title: Create unit test method stubs
33
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.
4-
ms.date: 12/04/2023
4+
ms.date: 11/25/2025
55
ms.topic: how-to
66
helpviewer_keywords:
77
- unit testing, create unit tests
88
author: mikejo5000
99
ms.author: mikejo
1010
manager: mijacobs
1111
ms.subservice: test-tools
12+
monikerRange: '<= vs-2022'
1213
---
1314
# Create unit test method stubs from code
1415

docs/test/improve-code-quality.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ Visual Studio is also extensible and opens the door for third-party unit testing
4141
> [!NOTE]
4242
> Live unit testing is available in Enterprise edition only and is only supported for .NET code.
4343
44-
## IntelliTest
44+
::: moniker range="visualstudio"
45+
## AI tools to generate tests
4546

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.
4748

48-
![IntelliTest in action](media/devtest-intellitest.png)
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
4951

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
5254

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/)
55-
* [IntelliTest reference manual](intellitest-manual/index.md)
55+
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
5657

5758
## Code coverage
5859

@@ -90,6 +91,26 @@ Code coverage is an option when you run test methods using Test Explorer. The re
9091

9192
::: moniker-end
9293

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+
![IntelliTest in action](media/devtest-intellitest.png)
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/)
105+
* [IntelliTest reference manual](intellitest-manual/index.md)
106+
107+
::: moniker range="visualstudio"
108+
[!INCLUDE [intellitest-deprecation](includes/intellitest-deprecation.md)]
109+
::: moniker-end
110+
::: moniker range="vs-2022"
111+
[!INCLUDE [intellitest-visual-studio-2022](includes/intellitest-visual-studio-2022.md)]
112+
::: moniker-end
113+
93114
::: moniker range="<=vs-2019"
94115
## User interface testing with Coded UI and Selenium
95116

docs/test/index.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ landingContent:
4343
url: getting-started-with-unit-testing.md
4444
- text: Run unit tests with Test Explorer
4545
url: run-unit-tests-with-test-explorer.md
46-
- text: Generate unit tests using AI (.NET)
47-
url: unit-testing-with-github-copilot-test-dotnet.md
4846
- linkListType: how-to-guide
4947
links:
5048
- text: Code coverage - Determine how much code is being tested
@@ -55,12 +53,12 @@ landingContent:
5553
linkLists:
5654
- linkListType: tutorial
5755
links:
56+
- text: Generate unit tests using AI (.NET)
57+
url: unit-testing-with-github-copilot-test-dotnet.md
5858
- text: Create and run unit tests for managed code
5959
url: walkthrough-creating-and-running-unit-tests-for-managed-code.md
6060
- text: Get started with Live Unit Testing
6161
url: live-unit-testing-start.md
62-
- text: Generate unit tests (IntelliTest)
63-
url: generate-unit-tests-for-your-code-with-intellitest.md
6462
- text: Test execution with Hot Reload
6563
url: test-execution-with-hot-reload.md
6664
- linkListType: how-to-guide

docs/test/unit-test-basics.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ Unit testing has the greatest effect on the quality of your code when it's an in
1818

1919
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).
2020

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-
2321
## Get started
2422

2523
For an introduction to unit testing that takes you directly into coding, see one of these articles:
2624

25+
::: moniker range="visualstudio"
26+
- [GitHub Copilot testing for .NET](../test/unit-testing-with-github-copilot-test-dotnet.md)
27+
::: moniker-end
2728
- [Walkthrough: Create and run unit tests for .NET code](../test/walkthrough-creating-and-running-unit-tests-for-managed-code.md)
2829

2930
- [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)
7576

7677
Now that we have some code, it's time for testing.
7778

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"
7894
## Create unit tests with Copilot
7995

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).
8197

8298
## Create unit test projects and test methods (C#)
8399

@@ -87,39 +103,46 @@ For C#, it is often quicker to generate the unit test project and unit test stub
87103

88104
1. From the code editor window, right-click and choose [**Create Unit Tests**](create-unit-tests-menu.md) from the right-click menu.
89105

90-
::: moniker range="vs-2019"
91-
![From the editor window, view the context menu](../test/media/vs-2019/basics-create-unit-tests.png)
106+
![From the editor window, view the context menu](../test/media/vs-2022/basics-create-unit-tests.png)
92107

93108
> [!NOTE]
94109
> 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
96110
97-
::: moniker range=">=vs-2022"
98-
![From the editor window, view the context menu](../test/media/vs-2022/basics-create-unit-tests.png)
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+
![Create Unit Tests dialog box in Visual Studio](../test/media/vs-2022/create-unit-tests.png)
114+
115+
3. The unit test stubs are created in a new unit test project for all the methods in the class.
116+
117+
![The unit tests are created](../test/media/vs-2022/basics-test-stub.png)
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+
![From the editor window, view the context menu](../test/media/vs-2019/basics-create-unit-tests.png)
99132

100133
> [!NOTE]
101134
> 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
103135
104136
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.
105137

106-
::: moniker range="<=vs-2019"
107138
![Create Unit Tests dialog box in Visual Studio](../test/media/create-unit-tests.png)
108-
::: moniker-end
109-
::: moniker range=">=vs-2022"
110-
![Create Unit Tests dialog box in Visual Studio](../test/media/vs-2022/create-unit-tests.png)
111-
::: moniker-end
112139

113140
3. The unit test stubs are created in a new unit test project for all the methods in the class.
114141

115-
::: moniker range="vs-2019"
116142
![The unit tests are created](../test/media/vs-2019/basics-test-stub.png)
117-
::: moniker-end
118-
::: moniker range=">=vs-2022"
119-
![The unit tests are created](../test/media/vs-2022/basics-test-stub.png)
120-
::: moniker-end
121143

122144
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
123146

124147
### Create the unit test project and unit tests manually
125148

docs/test/unit-test-your-code.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Explore unit test tools and tasks
33
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
55
ms.topic: article
66
helpviewer_keywords:
77
- Visual Studio, unit tests
@@ -28,7 +28,14 @@ The unit test tools include:
2828

2929
* **Microsoft Fakes isolation framework**&mdash;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.
3030

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"
3137
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.
38+
::: moniker-end
3239

3340
## Key tasks
3441

docs/test/walkthrough-creating-and-running-unit-tests-for-managed-code.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ This article steps you through creating, running, and customizing a series of un
2121

2222
This article describes how to manually create unit tests. If you would like to generate tests automatically from existing code, see the following articles:
2323

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"
2429
- [Create unit test method stubs from code](../test/create-unit-tests-menu.md)
2530
- [Use slash commands in GitHub Copilot](../ide/copilot-chat-context.md#slash-commands)
31+
::: moniker-end
2632

2733
## Prerequisites
2834

0 commit comments

Comments
 (0)