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
The Chat view in Visual Studio Code provides three modes that can be used to create unit tests: Ask, Edit, and Agent. Each mode has its own strengths and weaknesses, and the best mode to use depends on the specific task at hand.
2
2
3
-
- The Ask mode is optimized for asking questions about your code projects, coding topics, and general technology concepts.
4
-
- The Edit mode is optimized for making edits across multiple files in your codebase.
5
-
- The Agent mode is optimized for starting an agentic coding workflow.
3
+
- The ask mode is optimized for asking questions about your code projects, coding topics, and general technology concepts.
4
+
- The edit mode is optimized for making edits across multiple files in your codebase.
5
+
- The agent mode is optimized for starting an agentic coding workflow.
6
6
7
7
> [!IMPORTANT]
8
-
> When you use the Chat view in Agent mode, GitHub Copilot may make multiple premium requests to complete a single task. This includes both user-initiated prompts and follow-up actions Copilot takes on your behalf. The total premium requests used will depend on the complexity of the task, the number of steps involved, and the model selected.
8
+
> When you use the Chat view in agent mode, GitHub Copilot may make multiple premium requests to complete a single task. Premium requests can be used by user-initiated prompts and follow-up actions Copilot takes on your behalf. The total premium requests used depends on the complexity of the task, the number of steps involved, and the model selected.
9
9
10
-
## Use the Chat view in Ask mode to create unit tests
10
+
## Use the ask mode to create unit tests
11
11
12
-
The Ask mode can be used to analyze a workspace and then create unit tests. This is useful when you want to create tests for multiple functions or methods in a file, or when you want to create tests for an entire file.
12
+
The ask mode can be used to analyze a workspace and then create unit tests. The ask mode is useful when you want to create tests for multiple functions or methods in a file, or when you want to create tests for an entire file.
13
13
14
-
To create unit tests using the Ask mode, follow these steps:
14
+
To create unit tests using the ask mode, follow these steps:
15
15
16
16
1. Open the file that contains the code you want to test.
17
17
18
-
1. Open the Chat view and start a new chat session using the **Ask** mode.
18
+
1. Open the Chat view and start a new chat session using the ask mode.
19
19
20
20
1. Add context to the chat session.
21
21
22
22
- You can add context to the chat session by dragging and dropping files from Visual Studio Code's EXPLORER view into the Chat view. You can also use the **Add Context** button.
23
-
- You can open external files in the code editor to include resources that aren't part of the workspace and use them to provide additional context. For example, you can open markdown files that contain contributor guidelines or contact information and then use the **Add Context** button to add them to the Chat view context.
24
-
- You can use the `@workspace` chat variable to specify the workspace as part of your prompt. This is useful when you want to create tests for multiple functions or methods in a file, or when you want to create tests for an entire file.
23
+
- You can open external files in the code editor to include resources that aren't part of the workspace and use them to provide specific context. For example, you can open markdown files that contain contributor guidelines or contact information and then use the **Add Context** button to add them to the Chat view context.
24
+
- You can use the `@workspace` chat variable to specify the workspace as part of your prompt. The workspace context is useful when you want to create tests for multiple functions or methods in a file, or when you want to create tests for an entire file.
25
25
26
26
1. Enter a prompt that asks for unit tests for the code in the file.
27
27
28
-
- For example: "`@workspace /explain` I need to create unit tests for the code in this file. The tests should be written in Python and use the unittest framework."
28
+
- For example: "`@workspace /explain I need to create unit tests for the code in this file. The tests should be written in Python and use the unittest framework.`"
29
29
30
-
1. Review the suggested unit tests, and refine the results using additional prompts if necessary.
30
+
1. Review the suggested unit tests, and refine the results using updated prompts if necessary.
31
31
32
32
1. Move the suggested unit tests into a test file.
33
33
34
34
- For example, create a test file in the same directory as the code file, and then insert the suggested unit tests into the file.
35
-
- You can use the Ask mode to suggest updates for specific tests after creating the test file, or use other GitHub Copilot tools to help with updates.
35
+
- You can use the ask mode to suggest updates for specific tests after creating the test file, or use other GitHub Copilot tools to help with updates.
36
36
- You can also use the **Apply in Editor** button to apply the suggested unit tests directly to the code file.
37
37
38
38
1. Save the test file.
39
39
40
-
- Test files are typically saved to a separate "tests" directory in a project that's configured for unit tests. Your options will depend on your project's structure and testing framework.
41
-
- You can use the Ask mode to suggest updates for specific tests after creating the test file, or use other GitHub Copilot tools to help with updates.
40
+
- Test files are typically saved to a separate "tests" directory in a project that's configured for unit tests. Your options depend on your project's structure and testing framework.
41
+
- You can use the ask mode to suggest updates for specific tests after creating the test file, or use other GitHub Copilot tools to help with updates.
42
42
43
43
1. Run the tests to ensure they pass and verify the functionality of your code.
44
44
45
-
1. If necessary, refine the tests by adding additional test cases or modifying existing ones.
45
+
1. If necessary, refine the tests by adding more test cases or modifying existing ones.
46
46
47
47
1. Save the file again after making any changes to the tests.
48
48
49
-
## Use the Chat view in Edit mode to create unit tests
49
+
## Use the edit mode to create unit tests
50
50
51
-
The Edit mode can be used to create unit tests by adding context files to the chat and then creating or updating test files. This is useful when you want to create tests for specific functions or methods in a file, or when you want to create tests for an entire file.
51
+
The edit mode can be used to create unit tests by adding context files to the chat and then creating or updating test files. The edit mode is useful when you want to create tests for specific functions or methods in a file, or when you want to create tests for an entire file.
52
52
53
-
To create unit tests using the Edit mode, follow these steps:
53
+
To create unit tests using the edit mode, follow these steps:
54
54
55
55
1. Open the file that contains the code you want to test.
56
56
57
-
1. Open the Chat view and start a new chat session using the **Edit** mode.
57
+
1. Open the Chat view and start a new chat session using the edit mode.
58
58
59
59
1. Add context to the chat session.
60
60
61
-
- Chat participants aren't available in Edit mode, so you can't specify `@workspace` as part of your prompt. However, you can add context to the chat session using `#codebase` and by dragging and dropping files or folders from Visual Studio Code's EXPLORER view into the Chat view. Use Visual Studio Code to open external files, such markdown files that contain contributor guidelines, and then use the **Add Context** button to add them to the chat context.
61
+
- Chat participants aren't available in edit mode, so you can't specify `@workspace` as part of your prompt. However, you can add context to the chat session using `#codebase` and by dragging and dropping files or folders from Visual Studio Code's EXPLORER view into the Chat view. Use Visual Studio Code to open external files, such markdown files that contain contributor guidelines, and then use the **Add Context** button to add them to the chat context.
62
62
63
63
1. Enter a prompt to create the intended unit tests.
64
64
65
-
- For example: "I need to create unit tests for the code in this file. The tests should be written in Python and use the unittest framework. Create a test file in the same directory as the code file."
65
+
- For example: "`I need to create unit tests for the code in this file. The tests should be written in Python and use the unittest framework. Create a test file in the same directory as the code file.`"
66
66
67
-
1. Review the test file created using Edit mode, and then save or discard the file.
67
+
1. Review the test file created using edit mode, and then save or discard the file.
68
68
69
-
- You can update the file using additional prompts to correct or enhance specific tests if necessary.
69
+
- You can update the file using new prompts to correct or enhance specific tests if necessary.
70
70
71
71
1. Save the test file.
72
72
73
-
- Test files are typically saved to a separate "tests" directory in a project that's configured for unit tests. Your options will depend on your project's structure and testing framework.
73
+
- Test files are typically saved to a separate "tests" directory in a project that's configured for unit tests. Your options depend on your project's structure and testing framework.
74
74
75
75
1. Run the tests to ensure they pass and verify the functionality of your code.
76
76
77
-
1. If necessary, refine the tests by adding additional test cases or modifying existing ones.
77
+
1. If necessary, refine the tests by adding more test cases or modifying existing ones.
78
78
79
79
1. Save the file again after making any changes to the tests.
80
80
81
-
## Use the Chat view in Agent mode to create unit tests
81
+
## Use the agent mode to create unit tests
82
82
83
-
The Agent mode can be used to automate tasks within your unit testing process. For example, you can use the Agent mode to scaffold a test project, create test files, run tests, generate test reports, or perform other tasks related to unit testing. The Agent mode is best for creating unit tests that require a more in-depth understanding of the project.
83
+
The agent mode can be used to automate tasks within your unit testing process. For example, you can use the agent mode to scaffold a test project, create test files, run tests, generate test reports, or perform other tasks related to unit testing. The agent mode is best for creating unit tests that require a more in-depth understanding of the project.
84
84
85
-
To create unit tests using the Agent mode, follow these steps:
85
+
To create unit tests using the agent mode, follow these steps:
86
86
87
87
1. Open the file that contains the code you want to test.
88
88
89
89
1. Open the Chat view and start a new chat session using the **Agent** mode.
90
90
91
-
1. Let Agent mode determine the context.
91
+
1. Let agent mode determine the context.
92
92
93
-
In Agent mode, you don't need to specify the context. Copilot will automatically determine the relevant context and files to edit.
93
+
In agent mode, you don't need to specify the context. Copilot will automatically determine the relevant context and files to edit.
94
94
95
95
1. Optionally, select the Tools icon to configure which tools can be used for responding to your request.
96
96
@@ -99,17 +99,17 @@ To create unit tests using the Agent mode, follow these steps:
99
99
100
100
1. Enter a prompt that defines the intended tasks.
101
101
102
-
- For example: "Ensure that a suitable unit tests project is prepared for the selected code file. Create a test file in the unit test project that includes unit tests for all methods in the selected file. Unit tests should be written in C# and use the xUnit framework. Run the tests to ensure expected results."
102
+
- For example: "`Ensure that a suitable unit tests project is prepared for the selected code file. Create a test file in the unit test project that includes unit tests for all methods in the selected file. Unit tests should be written in C# and use the xUnit framework. Run the tests to ensure expected results.`"
103
103
104
-
1. Monitor the progress of the Agent mode as it performs the tasks.
104
+
1. Monitor the progress of the agent mode as it performs the tasks.
105
105
106
-
- Confirm tool invocations and terminal commands. You can confirm or reject the tool invocations and terminal commands that Agent mode suggests. For example, you can confirm the command to run the tests or the command to generate a test report.
107
-
- Interrupt the Agent mode if necessary. You can interrupt the Agent mode if you want to stop the tasks that it's performing. For example, you can interrupt the Agent mode if you want to change the context or if you want to change the tools that are being used.
106
+
- Confirm tool invocations and terminal commands. You can confirm or reject the tool invocations and terminal commands that agent mode suggests. For example, you can confirm the command to run the tests or the command to generate a test report.
107
+
- Interrupt the agent mode if necessary. You can interrupt the agent mode if you want to stop the tasks that it's performing. For example, you can interrupt the agent mode if you want to change the context or if you want to change the tools that are being used.
108
108
109
-
1. Review the files tat Agent more created or updated during the specified tasks, and then keep or discard updates.
109
+
1. Review the files that agent mode created or updated during the specified tasks, and then keep or discard updates.
110
110
111
-
- You can use additional prompts to correct or enhance specific tests if necessary.
111
+
- You can use new prompts to correct or enhance specific tests if necessary.
112
112
113
113
## Summary
114
114
115
-
GitHub Copilot's Chat view provides three modes that can be used to create unit tests: Ask, Edit, and Agent. Each mode has its own strengths and weaknesses, and the best mode to use depends on the specific task at hand. The Ask mode is optimized for asking questions about your code projects, coding topics, and general technology concepts. The Edit mode is optimized for making edits across multiple files in your codebase. The Agent mode is optimized for starting an agentic coding workflow.
115
+
GitHub Copilot's Chat view provides three modes that can be used to create unit tests: Ask, Edit, and Agent. Each mode has its own strengths and weaknesses, and the best mode to use depends on the specific task at hand. The ask mode is optimized for asking questions about your code projects, coding topics, and general technology concepts. The edit mode is optimized for making edits across multiple files in your codebase. The agent mode is optimized for starting an agentic coding workflow.
Copy file name to clipboardExpand all lines: learn-pr/wwl-azure/develop-unit-tests-using-github-copilot-tools/includes/6-exercise-develop-unit-tests-github-copliot.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
> [!IMPORTANT]
2
-
> To complete this exercise, you need an active GitHub account and a Visual Studio Code environment configured for C# development. For help configuring your lab environment, see [Configure lab environment for GitHub Copilot Labs](https://go.microsoft.com/fwlink/?linkid=2320147&azure-portal=true). For help enabling GitHub Copilot in Visual Studio Code, see [Enable GitHub Copilot in Visual Studio Code](https://go.microsoft.com/fwlink/?linkid=2320158&azure-portal=true).
2
+
> To complete this exercise, you need an active GitHub account and a Visual Studio Code environment configured for C# development. For help with configuring your lab environment, see [Configure lab environment for GitHub Copilot Labs](https://go.microsoft.com/fwlink/?linkid=2320147&azure-portal=true). For help with enabling GitHub Copilot in Visual Studio Code, see [Enable GitHub Copilot in Visual Studio Code](https://go.microsoft.com/fwlink/?linkid=2320158&azure-portal=true).
3
3
4
4
In this exercise, you use GitHub Copilot to accelerate the development of unit tests for a C# application. Tasks include:
Copy file name to clipboardExpand all lines: learn-pr/wwl-azure/develop-unit-tests-using-github-copilot-tools/index.yml
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -27,11 +27,11 @@ prerequisites: |
27
27
28
28
- Experience developing C# applications using Visual Studio Code and the C# Dev Kit extension is recommended.
29
29
30
-
- An active subscription for GitHub Copilot is required for either your personal GitHub account or a GitHub account managed by an organization or enterprise. You can set up a GitHub Copilot Free account or signup for a subscription to GitHub Copilot Pro trial with a one-time 30-day trial. For learning, the Copilot Free option with usage limits should be sufficient.
30
+
- An active subscription for GitHub Copilot is required for either your personal GitHub account or a GitHub account managed by an organization or enterprise. You can set up a GitHub Copilot Free plan or sign-up for a GitHub Copilot Pro subscription with a one-time 30-day free trial. For this training, signing up for a GitHub Copilot Free plan is sufficient.
31
31
32
-
- Awareness of the GitHub Copilot free trial conditions: if you choose the free trial offer for GitHub Copilot, a form of payment is requested at sign-up. Charges aren't applied until the trial is over, unless you cancel before the conclusion of the 30-day period.
32
+
- Awareness of the GitHub Copilot free trial conditions: if you choose the 30-day free trial offer for GitHub Copilot Pro, a form of payment is requested at sign-up. Charges aren't applied until the trial is over, unless you cancel before the conclusion of the 30-day period.
33
33
34
-
- Experience using the GitHub Copilot and GitHub Copilot Chat extensions for Visual Studio Code to generate autocompletion suggestions and explain existing code.
34
+
- Experience using GitHub Copilot in Visual Studio Code to explain, debug, and generate code.
0 commit comments