Skip to content

Commit 4a79e11

Browse files
committed
edits
1 parent 4b5a9e4 commit 4a79e11

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

docs/test/unit-test-basics.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,21 @@ Now that we have some code, it's time for testing.
7979
::: moniker range="visualstudio"
8080
## Create unit tests with Copilot
8181

82-
Starting in Visual Studio 2026 Insiders build, you can use GitHub Copilot testing for .NET to automatically generate unit tests. 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.
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.
8383

8484
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).
8585

8686
### Generate and run unit tests
8787

8888
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.
8989

90-
GitHub Copilot testing for .NET not only generates the tests, but debugs the tests, and runs them in Test Explorer. 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).
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).
9191
::: moniker-end
9292

93-
::: moniker range="<= vs-2022"
93+
::: moniker range="vs-2022"
9494
## Create unit tests with Copilot
9595

96-
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).
9797

9898
## Create unit test projects and test methods (C#)
9999

@@ -103,37 +103,43 @@ For C#, it is often quicker to generate the unit test project and unit test stub
103103

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

106-
::: moniker range="vs-2019"
107-
![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)
108107

109108
> [!NOTE]
110109
> 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.
111-
::: moniker-end
112110
113-
::: moniker range=">=vs-2022"
114-
![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)
115132

116133
> [!NOTE]
117134
> 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.
118-
::: moniker-end
119135
120136
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.
121137

122-
::: moniker range="<=vs-2019"
123138
![Create Unit Tests dialog box in Visual Studio](../test/media/create-unit-tests.png)
124-
::: moniker-end
125-
::: moniker range=">=vs-2022"
126-
![Create Unit Tests dialog box in Visual Studio](../test/media/vs-2022/create-unit-tests.png)
127-
::: moniker-end
128139

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

131-
::: moniker range="vs-2019"
132142
![The unit tests are created](../test/media/vs-2019/basics-test-stub.png)
133-
::: moniker-end
134-
::: moniker range=">=vs-2022"
135-
![The unit tests are created](../test/media/vs-2022/basics-test-stub.png)
136-
::: moniker-end
137143

138144
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.
139145
::: moniker-end

0 commit comments

Comments
 (0)