Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this article, you'll learn how to create, run, and test C# code using GitHub Copilot testing for .NET.
Although Copilot can generate unit tests, you get extra testing capability by using GitHub Copilot testing for .NET in Visual Studio, including the following:
- Unit tests are generated in a separate project within the solution.
- Copilot generates tests deterministically, grounded in the C# compiler and language semantics, so assertions and edge cases are predictable and type-safe.
- GitHub Copilot testing builds the unit tests following test generation. If there are errors, the unit testing capability in GitHub Copilot for .NET tries to identify and fix errors, and then re-runs the tests.
- GitHub Copilot testing runs the tests using Test Explorer.
GitHub Copilot testing for .NET generates tests for C# projects only using the MSTest, NUnit, and xUnit frameworks.
Prerequisites
To get started, you need:
- Visual Studio 2026 Insiders build
- Sign in to Visual Studio using a GitHub account with Copilot access
Tip
For the best experience, we suggest using a paid Copilot subscription to avoid potential throttling and ensure consistent access.
Generate and run tests
Open an existing C# project that needs new tests, or create a new C# project.
If you create a new project, you can use the Bank sample code to test the feature. Copy the starting sample code from Create and run unit tests for .NET into
Program.cs.Build the project.
Make sure the project builds without errors to simplify the process.
Open Copilot Chat by selecting the GitHub Copilot Chat button.
Use the following syntax in the Chat window to start GitHub Copilot testing and generate tests:
@test #targetwhere
#targetcan be the name of a solution, project, file, class, or member.For the
Bankexample, you can type@test #BankAccount, specifying the class name.
In the Chat window, select Send.
GitHub Copilot testing for .NET initiates an iterative process of analyzing your code, creating a new project for the unit tests, generating tests, building, and running the tests.
Test generation is a long-running process. Depending on the scope of your target (file, project, solution, etc.) it may take a while.

When unit tests are generated, the tests appear in a separate test project in the solution.

Test Explorer shows the results. If Test Explorer is not automatically opened by GitHub Copilot testing, select Test > Test Explorer.

At this point, you can manually use Test Explorer to continue running tests, or chat with Copilot about the test results. You can also use Copilot to debug failed tests. For more information, see Debug unit tests.