Repository: dotnet/docs
Pull request #44228: Added article Generate Unit Tests with Copilot
Author: login: sigmade
Labels: name: dotnet-fundamentals/svc
name: community-contribution
description: Indicates PR is created by someone from the .NET community.
Created: 2025-01-12T10:20:24Z | Merged: 2025-03-20T16:50:14Z

## Summary

Added article about Generate Unit Tests with Copilot and Visual Studio


<!-- PREVIEW-TABLE-START -->

---

#### Internal previews

| 📄 File | 🔗 Preview link |
|:--|:--|
| [docs/core/testing/unit-testing-with-copilot.md](https://github.com/dotnet/docs/blob/b242c660da9aa82cc4fffc239067affd2708453d/docs/core/testing/unit-testing-with-copilot.md) | [Generate unit tests with GitHub Copilot](https://review.learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-copilot?branch=pr-en-us-44228) |
| [docs/navigate/devops-testing/toc.yml](https://github.com/dotnet/docs/blob/b242c660da9aa82cc4fffc239067affd2708453d/docs/navigate/devops-testing/toc.yml) | [docs/navigate/devops-testing/toc](https://review.learn.microsoft.com/en-us/dotnet/navigate/devops-testing/toc?branch=pr-en-us-44228) |


<!-- PREVIEW-TABLE-END -->


Diff:
diff --git a/docs/core/testing/media/create-unit-test-window.png b/docs/core/testing/media/create-unit-test-window.png
new file mode 100644
index 0000000000000..b69b1dfd51d61
Binary files /dev/null and b/docs/core/testing/media/create-unit-test-window.png differ
diff --git a/docs/core/testing/media/create-unit-test.png b/docs/core/testing/media/create-unit-test.png
new file mode 100644
index 0000000000000..2f8700eab0410
Binary files /dev/null and b/docs/core/testing/media/create-unit-test.png differ
diff --git a/docs/core/testing/media/test-copilot-prompt.png b/docs/core/testing/media/test-copilot-prompt.png
new file mode 100644
index 0000000000000..a1799f73a2634
Binary files /dev/null and b/docs/core/testing/media/test-copilot-prompt.png differ
diff --git a/docs/core/testing/media/test-copilot-result.png b/docs/core/testing/media/test-copilot-result.png
new file mode 100644
index 0000000000000..e1ce26b17dbe2
Binary files /dev/null and b/docs/core/testing/media/test-copilot-result.png differ
diff --git a/docs/core/testing/media/test-mehod-stub.png b/docs/core/testing/media/test-mehod-stub.png
new file mode 100644
index 0000000000000..a696b28f18db5
Binary files /dev/null and b/docs/core/testing/media/test-mehod-stub.png differ
diff --git a/docs/core/testing/unit-testing-with-copilot.md b/docs/core/testing/unit-testing-with-copilot.md
new file mode 100644
index 0000000000000..0cbbae283953a
--- /dev/null
+++ b/docs/core/testing/unit-testing-with-copilot.md
@@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate unit tests with GitHub Copilot
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Create a test project
+
+Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await cacheClient.GetProduct(productId);
+
+        if (product is not null)
+        {
+            return product;
+        }
+
+        product = await productDataStorage.GetProduct(productId);
+
+        if (product is not null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+- Select the method.
+- Right-click and select **Create Unit Tests**.
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
+
+In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
+
+> [!NOTE]
+> The **Create Unit Tests** command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension [xUnit.net.TestGenerator2022](https://marketplace.visualstudio.com/items?itemName=YowkoTsai.xunitnettestgenerator2022).
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves
+
+- Select the method being tested again.
+- Right-click - **Ask Copilot**.
+- Enter a simple prompt, such as:
+
+  "generate unit tests using xunit, nsubstitute and insert the result into #ProductServiceTests file."
+  
+  You need to select your test class when you type the `#` character.
+
+> [!TIP]
+> For quick search, it's desirable that `ProductServiceTests` is open in a separate tab.
+
+:::image type="content" source="media/test-copilot-prompt.png" lightbox="media/test-copilot-prompt.png" alt-text="Prompt for generate tests":::
+
+Execute the prompt, click **Accept**, and Copilot generates the test code. After that, it remains to install the necessary packages.
+
+When the packages are installed, the tests can be run. This example worked on the first try: Copilot knows very well how to work with NSubstitute, and all dependencies were defined through interfaces.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated tests":::
+
+Thus, using **Visual Studio** in combination with **GitHub Copilot** significantly simplifies the process of generating and writing unit tests.
diff --git a/docs/navigate/devops-testing/toc.yml b/docs/navigate/devops-testing/toc.yml
index 6cf1945e7a277..a9a01423e1e7d 100644
--- a/docs/navigate/devops-testing/toc.yml
+++ b/docs/navigate/devops-testing/toc.yml
@@ -53,6 +53,8 @@ items:
               - name: Organize a project and test with xUnit
                 href: ../../core/tutorials/testing-with-cli.md
                 displayName: tutorials, cli
+              - name: Generate unit tests with GitHub Copilot
+                href: ../../core/testing/unit-testing-with-copilot.md
           - name: NUnit
             items:
               - name: C# unit testing


Reviews:
user: login: IEvangelist
body: Let's get some of this feedback added and look at it again. Also, this is going to need to have a TOC.yml entry.
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-01-17T19:11:04Z
user: login: IEvangelist
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-20T16:14:32Z
user: login: IEvangelist
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-20T16:14:55Z
user: login: IEvangelist
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-20T16:15:05Z
user: login: IEvangelist
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-20T16:15:13Z
user: login: IEvangelist
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-20T16:34:14Z
user: login: IEvangelist
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-20T16:37:21Z

Review comments:
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: We don't link to authors in .NET docs, that's a legacy ASP.NET Core docs thing.

```suggestion

# Generate Unit Tests with GitHub Copilot and Visual Studio

In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
```
created_at: 2025-01-14T17:44:32Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
## Generate a test project and a stub method
```
created_at: 2025-01-14T17:45:44Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
```
created_at: 2025-01-14T17:46:10Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
```
created_at: 2025-01-14T17:46:33Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
        var product = await cacheClient.GetProduct(productId);
```
created_at: 2025-01-14T17:46:41Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
        if (product is not null)
```
created_at: 2025-01-14T17:46:52Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
        product = await productDataStorage.GetProduct(productId);
```
created_at: 2025-01-14T17:46:59Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
        if (product is not null)
```
created_at: 2025-01-14T17:47:10Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+* Select the method.
+* Right-click and select 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀. 
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
- Select the method.
- Right-click and select **Create Unit Tests**.
```
created_at: 2025-01-14T17:47:53Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+* Select the method.
+* Right-click and select 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀. 
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀":::
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
```
created_at: 2025-01-14T17:48:11Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+* Select the method.
+* Right-click and select 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀. 
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀":::
+
+In the dialog that appears, select xUnit from the Test Framework dropdown menu
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
+
+* Select the method being tested again.
+* Right-click - Ask Copilot.
+* Enter a simple prompt, such as: <br> `generate unit tests using xunit, nsubstitute and insert the result into ProductServiceTests`</br> You need to select your test class using #. 
+
+> [!TIP]
+> For quick search, it is desirable that `ProductServiceTests` is open in a separate tab.
+
+:::image type="content" source="media/test-copilot-prompt.png" lightbox="media/test-copilot-prompt.png" alt-text="Prompt for generate tests":::
+
+Execute the prompt, click Accept, and Copilot generates the test code. After that, it remains to install the necessary packages.
+
+When the packages are installed, the tests can be run. This example worked on the first try: Copilot knows very well how to work with NSubstitute, and all dependencies were defined through interfaces. 
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated tests":::
+
+Thus, using 𝗩𝗶𝘀𝘂𝗮𝗹 𝗦𝘁𝘂𝗱𝗶𝗼 in combination with 𝗚𝗶𝘁𝗛𝘂𝗯 𝗖𝗼𝗽𝗶𝗹𝗼𝘁 significantly simplifies the process of generating and writing unit tests. 
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
Thus, using **Visual Studio** in combination with **GitHub Copilot** significantly simplifies the process of generating and writing unit tests. 
```
created_at: 2025-01-14T17:51:47Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+* Select the method.
+* Right-click and select 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀. 
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀":::
+
+In the dialog that appears, select xUnit from the Test Framework dropdown menu
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
+
+* Select the method being tested again.
+* Right-click - Ask Copilot.
+* Enter a simple prompt, such as: <br> `generate unit tests using xunit, nsubstitute and insert the result into ProductServiceTests`</br> You need to select your test class using #. 
+
+> [!TIP]
+> For quick search, it is desirable that `ProductServiceTests` is open in a separate tab.
+
+:::image type="content" source="media/test-copilot-prompt.png" lightbox="media/test-copilot-prompt.png" alt-text="Prompt for generate tests":::
+
+Execute the prompt, click Accept, and Copilot generates the test code. After that, it remains to install the necessary packages.
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
Execute the prompt, click **Accept**, and Copilot generates the test code. After that, it remains to install the necessary packages.
```
created_at: 2025-01-14T17:52:04Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+* Select the method.
+* Right-click and select 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀. 
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀":::
+
+In the dialog that appears, select xUnit from the Test Framework dropdown menu
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
+
+* Select the method being tested again.
+* Right-click - Ask Copilot.
+* Enter a simple prompt, such as: <br> `generate unit tests using xunit, nsubstitute and insert the result into ProductServiceTests`</br> You need to select your test class using #. 
+
+> [!TIP]
+> For quick search, it is desirable that `ProductServiceTests` is open in a separate tab.
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
> For quick search, it's desirable that `ProductServiceTests` is open in a separate tab.
```
created_at: 2025-01-14T17:59:15Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+By [Yegor Sychev](https://github.com/sigmade)
+
+This article explores how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generating a test project and a stub Method
+
+There is a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    private readonly IProductDataStorage _productDataStorage = productDataStorage;
+    private readonly ICacheClient _cacheClient = cacheClient;
+
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await _cacheClient.GetProduct(productId);
+
+        if (product != null)
+        {
+            return product;
+        }
+
+        product = await _productDataStorage.GetProduct(productId);
+
+        if (product != null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+* Select the method.
+* Right-click and select 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀. 
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command 𝗖𝗿𝗲𝗮𝘁𝗲 𝗨𝗻𝗶𝘁 𝗧𝗲𝘀𝘁𝘀":::
+
+In the dialog that appears, select xUnit from the Test Framework dropdown menu
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
```
created_at: 2025-01-15T14:32:16Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project and a stub method
+
+Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await cacheClient.GetProduct(productId);
+
+        if (product is not null)
+        {
+            return product;
+        }
+
+        product = await productDataStorage.GetProduct(productId);
+
+        if (product is not null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+- Select the method.
+- Right-click and select **Create Unit Tests**.
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
+
+In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
+
+* Select the method being tested again.
+* Right-click - Ask Copilot.
+* Enter a simple prompt, such as: <br> `generate unit tests using xunit, nsubstitute and insert the result into ProductServiceTests`</br> You need to select your test class using #. 
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
- Select the method being tested again.
- Right-click - **Ask Copilot**.
- Enter a simple prompt, such as:

  "generate unit tests using xunit, nsubstitute and insert the result into #ProductServiceTests file."
  
  You need to select your test class when you type the `#` character.
```
created_at: 2025-03-20T16:12:23Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project and a stub method
+
+Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await cacheClient.GetProduct(productId);
+
+        if (product is not null)
+        {
+            return product;
+        }
+
+        product = await productDataStorage.GetProduct(productId);
+
+        if (product is not null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+- Select the method.
+- Right-click and select **Create Unit Tests**.
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
+
+In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
## Generate the tests themselves
```
created_at: 2025-03-20T16:12:58Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project and a stub method
+
+Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await cacheClient.GetProduct(productId);
+
+        if (product is not null)
+        {
+            return product;
+        }
+
+        product = await productDataStorage.GetProduct(productId);
+
+        if (product is not null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+- Select the method.
+- Right-click and select **Create Unit Tests**.
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
+
+In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
> The **Create Unit Tests** command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension [xUnit.net.TestGenerator2022](https://marketplace.visualstudio.com/items?itemName=YowkoTsai.xunitnettestgenerator2022).
```
created_at: 2025-03-20T16:13:32Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project and a stub method
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
## Generate a test project
```
created_at: 2025-03-20T16:14:00Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
# Generate unit tests with GitHub Copilot
```
created_at: 2025-03-20T16:14:14Z
author_association: MEMBER
diff_hunk: @@ -53,6 +53,8 @@ items:
               - name: Organize a project and test with xUnit
                 href: ../../core/tutorials/testing-with-cli.md
                 displayName: tutorials, cli
+              - name: Generate Unit Tests with GitHub Copilot and Visual Studio
path: docs/navigate/devops-testing/toc.yml
user: login: IEvangelist
body: ```suggestion
              - name: Generate Unit Tests with GitHub Copilot
```
created_at: 2025-03-20T16:14:54Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project and a stub method
+
+Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await cacheClient.GetProduct(productId);
+
+        if (product is not null)
+        {
+            return product;
+        }
+
+        product = await productDataStorage.GetProduct(productId);
+
+        if (product is not null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+- Select the method.
+- Right-click and select **Create Unit Tests**.
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
+
+In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
+
+* Select the method being tested again.
+* Right-click - Ask Copilot.
+* Enter a simple prompt, such as: <br> `generate unit tests using xunit, nsubstitute and insert the result into ProductServiceTests`</br> You need to select your test class using #. 
+
+> [!TIP]
+> For quick search, it's desirable that `ProductServiceTests` is open in a separate tab.
+
+:::image type="content" source="media/test-copilot-prompt.png" lightbox="media/test-copilot-prompt.png" alt-text="Prompt for generate tests":::
+
+Execute the prompt, click **Accept**, and Copilot generates the test code. After that, it remains to install the necessary packages.
+
+When the packages are installed, the tests can be run. This example worked on the first try: Copilot knows very well how to work with NSubstitute, and all dependencies were defined through interfaces. 
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated tests":::
+
+Thus, using **Visual Studio** in combination with **GitHub Copilot** significantly simplifies the process of generating and writing unit tests. 
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
Thus, using **Visual Studio** in combination with **GitHub Copilot** significantly simplifies the process of generating and writing unit tests.

```
created_at: 2025-03-20T16:15:05Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,80 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate Unit Tests with GitHub Copilot and Visual Studio
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project and a stub method
+
+Imagine that there's a `ProductService` class with a `GetProductById` method that depends on the `IProductDataStorage` and `ICacheClient` interfaces.
+
+```csharp
+public class ProductService(
+    IProductDataStorage productDataStorage,
+    ICacheClient cacheClient)
+{
+    public async Task<Product?> GetProductById(int productId)
+    {
+        var product = await cacheClient.GetProduct(productId);
+
+        if (product is not null)
+        {
+            return product;
+        }
+
+        product = await productDataStorage.GetProduct(productId);
+
+        if (product is not null)
+        {
+            await _cacheClient.SetProduct(product);
+        }
+
+        return product;
+    }
+}
+```
+
+To generate a test project and a stub method, follow these steps:
+
+- Select the method.
+- Right-click and select **Create Unit Tests**.
+
+:::image type="content" source="media/create-unit-test.png" lightbox="media/create-unit-test.png" alt-text="Command Create Unit Tests":::
+
+In the **Create Unit Tests** dialog, select **xUnit** from the **Test Framework** dropdown menu.
+
+> [!NOTE]
+> The "Create Unit Tests" command defaults to the MSTest framework. However, since this example uses xUnit, you need to install the Visual Studio extension xUnit.net.TestGenerator2022.
+
+:::image type="content" source="media/create-unit-test-window.png" lightbox="media/create-unit-test-window.png" alt-text="Create Unit Tests window":::
+
+* If you don't have a test project yet, choose "New Test Project" or select an existing one.
+* If necessary, specify a template for the namespace, class, and method name, then click OK.
+
+After a few seconds, Visual Studio will pull in the necessary packages, and we will get a generated xUnit project with the required packages, structure, a reference to the project being tested, and with the `ProductServiceTests` class and a stub method.
+
+:::image type="content" source="media/test-mehod-stub.png" lightbox="media/test-mehod-stub.png" alt-text="Generated stub method":::
+
+## Generate the tests themselves:
+
+* Select the method being tested again.
+* Right-click - Ask Copilot.
+* Enter a simple prompt, such as: <br> `generate unit tests using xunit, nsubstitute and insert the result into ProductServiceTests`</br> You need to select your test class using #. 
+
+> [!TIP]
+> For quick search, it's desirable that `ProductServiceTests` is open in a separate tab.
+
+:::image type="content" source="media/test-copilot-prompt.png" lightbox="media/test-copilot-prompt.png" alt-text="Prompt for generate tests":::
+
+Execute the prompt, click **Accept**, and Copilot generates the test code. After that, it remains to install the necessary packages.
+
+When the packages are installed, the tests can be run. This example worked on the first try: Copilot knows very well how to work with NSubstitute, and all dependencies were defined through interfaces. 
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
When the packages are installed, the tests can be run. This example worked on the first try: Copilot knows very well how to work with NSubstitute, and all dependencies were defined through interfaces.
```
created_at: 2025-03-20T16:15:13Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,84 @@
+---
+title: Generate Unit Tests with Copilot
+author: sigmade
+description: How to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot
+ms.date: 01/12/2025
+---
+
+# Generate unit tests with GitHub Copilot
+
+In this article, you explore how to generate unit tests and test projects in C# using the xUnit framework with the help of Visual Studio commands and GitHub Copilot.
+
+## Generate a test project
path: docs/core/testing/unit-testing-with-copilot.md
user: login: IEvangelist
body: ```suggestion
## Create a test project
```
created_at: 2025-03-20T16:34:14Z
author_association: MEMBER
diff_hunk: @@ -53,6 +53,8 @@ items:
               - name: Organize a project and test with xUnit
                 href: ../../core/tutorials/testing-with-cli.md
                 displayName: tutorials, cli
+              - name: Generate Unit Tests with GitHub Copilot
path: docs/navigate/devops-testing/toc.yml
user: login: IEvangelist
body: ```suggestion
              - name: Generate unit tests with GitHub Copilot
```
created_at: 2025-03-20T16:37:21Z
author_association: MEMBER

PR comments:
user: login: sigmade
created_at: 2025-01-12T10:59:29Z
body: @dotnet-policy-service agree
author_association: CONTRIBUTOR
user: login: sigmade
created_at: 2025-01-14T07:59:18Z
body: @IEvangelist Could you please tell me what I'm doing wrong? An error appears Please fix OPS build warnings before merging
author_association: CONTRIBUTOR
user: login: sigmade
created_at: 2025-01-18T07:23:44Z
body: @IEvangelist  Thanks for the edits! I accepted commit changes and also corrected TOC.yml
author_association: CONTRIBUTOR
user: login: IEvangelist
created_at: 2025-03-11T14:36:42Z
body: Hey there, @sigmade - sorry, still playing catch up...could you please address the merge conflict here and I'll have another review? This is starting to shape up nicely.
author_association: MEMBER
user: login: sigmade
created_at: 2025-03-11T15:01:20Z
body: > Hey there, @sigmade - sorry, still playing catch up...could you please address the merge conflict here and I'll have another review? This is starting to shape up nicely.

Hi! done
author_association: CONTRIBUTOR
user: login: IEvangelist
created_at: 2025-03-20T16:27:00Z
body: @sigmade - I'm confused, whenever I was providing suggestions—they were being resolved without any changes. Some of these things are required in order for this content. I'm making these suggestions to resolve issues in the content and address linting warnings.
author_association: MEMBER
user: login: sigmade
created_at: 2025-03-20T16:31:24Z
body: > @sigmade - I'm confused, whenever I was providing suggestions—they were being resolved without any changes. Some of these things are required in order for this content. I'm making these suggestions to resolve issues in the content and address linting warnings.

I just resolved it
author_association: CONTRIBUTOR
user: login: IEvangelist
created_at: 2025-03-20T16:32:56Z
body: > > @sigmade - I'm confused, whenever I was providing suggestions—they were being resolved without any changes. Some of these things are required in order for this content. I'm making these suggestions to resolve issues in the content and address linting warnings.
> 
> I just resolved it

Right, but selecting "Resolve" doesn't take any action on the suggestion. It just dismisses it.
author_association: MEMBER
user: login: sigmade
created_at: 2025-03-20T16:46:05Z
body: > > > @sigmade - I'm confused, whenever I was providing suggestions—they were being resolved without any changes. Some of these things are required in order for this content. I'm making these suggestions to resolve issues in the content and address linting warnings.
> > 
> > 
> > I just resolved it
> 
> Right, but selecting "Resolve" doesn't take any action on the suggestion. It just dismisses it.

It's my fault. I should have chosen - Commit suggestion
author_association: CONTRIBUTOR