Generate unit and integration tests with GitHub Copilot
GitHub's tutorial uses Copilot Chat to write a unit test suite for a class, then integration tests that mock an external notification service, and then asks what coverage is still missing.
The problem
Tests for legacy or fast-moving code often never get written. An agent can quickly draft edge-case and mock-heavy tests, leaving developers to review them and fill gaps.
Steps
- Open the file you want to test and start Copilot Chat in your IDE.
- Use the /tests slash command, or write a detailed prompt that lists scenarios, edge cases and error handling.
- For integration tests, ask Copilot to mock external services such as a notification system.
- Keep existing test files open in nearby tabs so Copilot follows your testing patterns.
- Run the suite, then ask Copilot which tests are still missing and add them.
From the official docs
/tests
Results
- A unit test suite that covers edge cases, exceptions and data validation.
- Integration tests that check mocked services with assertions such as assert_called_once_with().
- A list of further tests needed to fill coverage gaps.
As reported by the source (GitHub Docs); AgentGid did not measure these figures.
This suits any developer already working in an IDE with Copilot, since the recipe needs only Copilot Chat, an existing test file for style, and a codebase you can review. Watch the credit pool: chat and agent mode draw on monthly GitHub AI Credits (Pro has 1,500), so big suites could use them up. Zed is open source, with a free Personal plan.
The agent used here
Similar use cases
JustHTML: a Python HTML5 parser built with coding agents that passes html5lib tests
A developer spent his off-hours using Copilot agent mode with several models to build a dependency-free HTML5 parser, and wrote up every stage, including a full restart.
JustHTML is about 3,000 lines of Python with 8,500+ tests passing.
Assign a GitHub issue to Copilot and get back a pull request
You assign an issue to Copilot just like a teammate. It works in the background, pushes its changes to a pull request and asks you to review it.
Copilot investigates the task, pushes its changes to a pull request and then requests your review.
How GitHub expanded secret validity checks with Copilot coding agent
GitHub's Secret Protection team had engineers do the research, then gave Copilot coding agent the repetitive work of adding validators for more leaked-token types. Coverage grew q…
As reported by GitHub: the team went from validating '32 partner token types' to onboarding 'almost 90 new types in just a few weeks'.
Guides
Best AI Agents in 2026: Live Rankings by Category
The leading AI agents for coding, design, research, data, marketing, sales, support, HR, finance, legal, DevOps and security, ranked by public usage data that refreshes daily, with prices and free options.
AI Agent Statistics 2026: Live Usage, Growth and Activity Data
Current statistics on AI agents from public data: package downloads, editor installs, GitHub stars, pull requests opened by coding agents, release pace and benchmark results. Updated daily.
Best AI Coding Agents in 2026: Ranked by Usage, Benchmarks and Price
The AI coding agents developers use most, with live download and install numbers, benchmark results, entry prices and a way to choose between terminal, IDE and cloud agents.