Skip to content

Commit ba04ee6

Browse files
authored
Add Copilot guides for debugging & testing (#8073)
* First draft of testing guide * Update testing guide and ToC * Add debugging with Copilot user guide * Update debugging guide * Add Copilot code review user guide placeholder * Remove code review guide from ToC * Update testing with Copilot * Update debug with Copilot * Remove metadata * Update debugging with Copilot * Update testing with Copilot * Add /fix functionality * Update metadata
1 parent 1c5304c commit ba04ee6

File tree

4 files changed

+215
-0
lines changed

4 files changed

+215
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
TOCTitle: Copilot Quickstart
3+
ContentId: 3d26d330-5e97-4748-83d1-351aaddcc60c
4+
PageTitle: Review code with Copilot
5+
DateApproved: 02/06/2025
6+
MetaDescription: Learn how to use GitHub Copilot in Visual Studio Code to review code.
7+
---
8+
# Review code with Copilot
9+
10+
This page is redirected to <https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review> and only exists to keep the "Review code with Copilot" TOC item.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
ContentId: 2f21c45a-8931-4da2-a921-af23a3b92949
3+
DateApproved: 02/06/2025
4+
MetaDescription: Learn how to use GitHub Copilot in Visual Studio Code to set up debugging configurations and fix issues during debugging.
5+
---
6+
7+
# Debug with GitHub Copilot
8+
9+
GitHub Copilot can help improve your debugging workflow in Visual Studio Code. Copilot can assist with the setup of the debug configuration for your project and provide suggestions for fixing issues discovered during debugging. This article gives an overview of how to use Copilot for debugging applications in VS Code.
10+
11+
Copilot can help with the following debugging tasks:
12+
13+
* **Configure debug settings**: generate and customize launch configurations for your project.
14+
* **Start a debugging session**: use `copilot-debug` to start a debugging session from the terminal.
15+
* **Fix issues**: receive suggestions for fixing issues discovered during debugging.
16+
17+
> [!TIP]
18+
> If you don't yet have a Copilot subscription, you can use Copilot for free by signing up for the [Copilot Free plan](https://github.com/github-copilot/signup) and get a monthly limit of completions and chat interactions.
19+
20+
## Set up debug configuration with Copilot
21+
22+
VS Code uses the `launch.json` file to store [debug configuration](/docs/editor/debugging-configuration.md). Copilot can help you create and customize this file to set up debugging for your project.
23+
24+
1. Open the Chat view (`kb(workbench.action.chat.open)`).
25+
1. Enter the `/startDebugging` command.
26+
1. Follow Copilot's guidance to set up debugging for your project.
27+
28+
Alternatively, you can use a natural language prompt like:
29+
30+
* "Create a debug configuration for a Django app"
31+
* "Set up debugging for a React Native app"
32+
* "Configure debugging for a Flask application"
33+
34+
## Start debugging with Copilot
35+
36+
The `copilot-debug` terminal command simplifies the process of configuring and starting a debugging session. Prefix the command you'd use for starting your application with `copilot-debug` to have Copilot automatically configure and start a debugging session.
37+
38+
1. Open the integrated terminal (`kb(workbench.action.terminal.toggleTerminal)`).
39+
40+
1. Enter `copilot-debug` followed by your application's start command. For example:
41+
42+
```bash
43+
copilot-debug node app.js
44+
```
45+
46+
or
47+
48+
```bash
49+
copilot-debug python manage.py
50+
```
51+
52+
1. Copilot launches a debugging session for your application. You can now use the built-in debugging features in VS Code.
53+
54+
Learn more about [debugging in VS Code](/docs/editor/debugging.md).
55+
56+
## Fix coding issues with Copilot
57+
58+
You can use Copilot Chat to help you fix coding issues or improve your code.
59+
60+
### Use chat prompts
61+
62+
1. Open your application code file.
63+
64+
1. Open one of these views:
65+
* Copilot Edits (`kb(workbench.action.chat.openEditSession)`)
66+
* Chat view (`kb(workbench.action.chat.open)`)
67+
* Inline Chat (`kb(inlineChat.start)`)
68+
69+
1. Enter a prompt like:
70+
* "/fix"
71+
* "Fix this #selection"
72+
* "Validate input for this function"
73+
* "Refactor this code"
74+
* "Improve the performance of this code"
75+
76+
Learn more about using [Copilot Chat](/docs/copilot/copilot-chat.md) and [Copilot Edits](/docs/copilot/copilot-edits.md) in VS Code.
77+
78+
### Use editor smart actions
79+
80+
To fix coding issues for your application code without writing a prompt, you can use the editor smart actions.
81+
82+
1. Open your application code file.
83+
1. Select the code you want to fix.
84+
1. Right-click and select **Copilot** > **Fix**.
85+
86+
Copilot provides a code suggestion to fix the code.
87+
88+
1. Optionally, refine the generated code by providing additional context in the chat prompt.
89+
90+
## Next steps
91+
92+
* Explore [general debugging features in VS Code](/docs/editor/debugging.md).
93+
* Learn more about [Copilot in VS Code](/docs/copilot/overview.md).
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
ContentId: 9f84b21e-5b76-4c3a-a5dd-2021ab343f1f
3+
DateApproved: 02/06/2025
4+
MetaDescription: Learn how to use GitHub Copilot in Visual Studio Code to write, debug, and fix tests.
5+
---
6+
7+
# Test with GitHub Copilot
8+
9+
Writing and maintaining tests is a crucial but often time-consuming part of software development. GitHub Copilot streamlines this process by helping you write, debug, and fix tests more efficiently in Visual Studio Code. This article shows you how to leverage Copilot's testing capabilities to improve your testing workflow and increase test coverage in your projects.
10+
11+
Copilot can help with the following testing tasks:
12+
13+
* **Set up testing frameworks**: get help configuring the right testing framework and VS Code extensions for your project and language.
14+
* **Generate test code**: create unit tests, integration tests, and end-to-end tests that cover your application code.
15+
* **Handle edge cases**: generate comprehensive test suites to cover edge cases and error conditions.
16+
* **Fix failing tests**: receive suggestions for fixing test failures.
17+
* **Maintain consistency**: personalize Copilot to generate tests that follow your project's coding practices.
18+
19+
> [!TIP]
20+
> If you don't yet have a Copilot subscription, you can use Copilot for free by signing up for the [Copilot Free plan](https://github.com/github-copilot/signup) and get a monthly limit of completions and chat interactions.
21+
22+
## Set up your testing framework
23+
24+
To accelerate your testing workflow, Copilot can help set up the testing framework and VS Code extensions for your project. Copilot suggests appropriate testing frameworks based on your project type.
25+
26+
1. Open the Chat view (`kb(workbench.action.chat.open)`).
27+
1. Enter the `/setupTests` command in the chat input field.
28+
1. Follow Copilot's guidance to configure your project.
29+
30+
## Write tests with Copilot
31+
32+
Copilot can help you write tests for your application code by generating test code that covers your codebase. This includes unit tests, end-to-end tests, and tests for edge cases.
33+
34+
### Use chat prompts
35+
36+
1. Open your application code file.
37+
38+
1. Open one of these views:
39+
* Copilot Edits (`kb(workbench.action.chat.openEditSession)`)
40+
* Chat view (`kb(workbench.action.chat.open)`)
41+
* Inline Chat (`kb(inlineChat.start)`)
42+
43+
1. Enter a prompt like:
44+
* "Generate tests for this code"
45+
* "Write unit tests including edge cases"
46+
* "Create integration tests for this module"
47+
48+
Get more guidance about [using GitHub Copilot for writing tests](https://docs.github.com/en/copilot/using-github-copilot/guides-on-using-github-copilot/writing-tests-with-github-copilot) in the GitHub documentation.
49+
50+
### Use editor smart actions
51+
52+
To generate tests for your application code without writing a prompt, you can use the editor smart actions.
53+
54+
1. Open your application code file.
55+
1. Optionally, select the code you want to test.
56+
1. Right-click and select **Copilot** > **Generate Tests**.
57+
58+
Copilot generates test code in an existing test file, or creates a new test file if one doesn't exist.
59+
60+
1. Optionally, refine the generated tests by providing additional context in the Inline Chat prompt.
61+
62+
## Fix failing tests
63+
64+
Copilot integrates with the Test Explorer in VS Code and can help with fixing failing tests.
65+
66+
1. In the Test Explorer, hover over a failing test
67+
1. Select the **Fix Test Failure** button (sparkle icon)
68+
1. Review and apply Copilot's suggested fix
69+
70+
Alternatively, you can:
71+
72+
1. Open the Chat view
73+
1. Enter the `/fixTestFailure` command
74+
1. Follow Copilot's suggestions to fix the test
75+
76+
> [!TIP]
77+
> [Copilot Edits agent mode (preview)](/docs/copilot/copilot-edits.md#use-agent-mode-preview) monitors the test output when running tests, and automatically attempts to fix and rerun failing tests.
78+
79+
## Personalize test generation
80+
81+
If your organization has specific testing requirements, you can customize how Copilot generates tests to ensure they meet your standards. You can personalize how Copilot generates tests by providing custom instructions. For example:
82+
83+
* Specify preferred testing frameworks
84+
* Define naming conventions for tests
85+
* Set code structure preferences
86+
* Request specific test patterns or methodologies
87+
88+
Get more information about [personalizing Copilot for generating tests](/docs/copilot/copilot-customization.md).
89+
90+
## Tips for better test generation
91+
92+
To get the best results when generating tests with Copilot, follow these tips:
93+
94+
* Provide context in your prompts about the testing framework you prefer
95+
* Specify if you want particular types of tests (unit, integration, end-to-end)
96+
* Ask for specific test cases or edge cases
97+
* Request tests that follow your project's coding standards
98+
99+
## Next steps
100+
101+
* Learn more about [Copilot in VS Code](/docs/copilot/overview.md).
102+
* Explore [general testing features in VS Code](/docs/editor/testing.md).
103+
* Check out example prompts for [generating unit tests](https://docs.github.com/en/copilot/example-prompts-for-github-copilot-chat/testing-code/generate-unit-tests)

docs/toc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@
104104
["Customizing Copilot", "/docs/copilot/copilot-customization"],
105105
["Best Practices", "/docs/copilot/prompt-crafting"],
106106
["Workspace Context", "/docs/copilot/workspace-context"],
107+
["", "", {
108+
"name": "Guides",
109+
"area": "copilot/guides",
110+
"topics": [
111+
["Test with Copilot", "/docs/copilot/guides/test-with-copilot"],
112+
["Debug with Copilot", "/docs/copilot/guides/debug-with-copilot"]
113+
]
114+
}
115+
],
107116
["Copilot Cheat Sheet", "/docs/copilot/copilot-vscode-features"],
108117
["Settings Reference", "/docs/copilot/copilot-settings"],
109118
["Copilot Extensibility", "/docs/copilot/copilot-extensibility-overview"],

0 commit comments

Comments
 (0)