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 as reported by GitHub
- 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.
These figures are as reported by GitHub in GitHub Docs ↗. GitHub sells the product used here. AgentGid did not measure or independently verify them.
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
How three Java Champions use GitHub Copilot for migration, testing and app building
Three experienced Java developers describe how they use GitHub Copilot in IDEs and agent workflows for feature work, a slide-deck migration, UI test reproduction and small apps. T…
As reported by the GitHub Blog (developer quotes): Vlad Mihalcea built an Optimizer event-history web app in two days, a task he expected to take wee…
GitHub rewrote its Copilot agent runtime in Rust with Copilot CLI
GitHub moved the agent runtime behind Copilot CLI, the Copilot app and the Copilot SDK from TypeScript on Node.js to Rust, with agents in the Copilot app and Copilot CLI writing m…
More than 800,000 lines of production Rust written, mostly by agents, across 128 pull requests that landed in main, as reported by GitHub.
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. (as reported by the author's blog)
Guides
Best AI Code Review Tools in 2026: CodeRabbit, Greptile, Graphite, Copilot and Open Source
AI code review agents for pull requests compared: what they check, how they are priced, open-source options and how to roll one out without drowning your team in comments.
AI Coding Agent Pricing Explained: Claude Code, Cursor, Codex and Copilot (2026)
What Claude Code, Cursor, OpenAI Codex, GitHub Copilot and other coding agents really cost: plan prices, usage limits, subscription vs API billing, and how to estimate your monthly bill.
What Is MCP (Model Context Protocol)? A Plain Guide and the Most Popular MCP Servers
What the Model Context Protocol is, how MCP servers and clients work, which AI agents support it, how to install a server safely, and the most-starred MCP servers by category.
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.