Use Copilot to add tests in a .NET repo
The .NET team had Copilot write tests in dotnet/runtime, where it was strongest on test work but sometimes missed older frameworks and CI cases.
- What they did
- Maintainers in dotnet/runtime handed Copilot coding agent test-writing jobs, including coverage improvements. The agent used coverage tooling, drafted tests, and a maintainer checked each pull request. They also gave it rules for the repo’s test style, such as not asserting exact exception text, using conditional test attributes, and avoiding tests that cannot run on .NET Framework.
- How it went
- Over ten months, test-related pull requests passed 75.6% of the time, across 99 PRs. The main problems were extra duplicate tests, tests that treated buggy behavior as correct, and failures on older frameworks or in CI.
- Tips
- Give the agent the repo’s testing rules up front, and ask it to verify the code on every supported framework, not just the latest one. Plan on pruning repeated tests and reviewing CI results, since a local pass may still miss configuration-specific failures.
Try it yourself with GitHub Copilot
In [owner/repo], add or expand tests for [class, method, or feature] using the project’s existing test style. Follow these rules: [list test conventions], avoid asserting exact exception wording, and do not rely on helpers that only work in one framework. First inspect the current coverage and propose the test cases you plan to add. Then write the tests and stop for my approval before you run anything that would submit changes or make irreversible edits. After I approve, check the tests against every supported [framework/version] and report any CI-only failures along with the exact files changed.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Use Copilot Agent Mode on notebook edits carefully
A user tried Copilot Agent Mode on a large Jupyter notebook and had to revert repeatedly after it damaged the file mid-edit.
Summarize a private repo’s app flow with Copilot
A developer used GitHub Copilot to map an app’s flow in a client’s private repo, then realized the work had happened under their own account.
Create a filtered summary page with Copilot
Copilot agent mode in Visual Studio 2022 built a charges report in a Razor Pages app, added navigation, and drafted the commit steps.
Run terminal commands carefully in Copilot agent mode
A VS Code user had Copilot agent mode run shell commands, but it often missed output or got stuck until they changed the shell setup.
Move a project from OpenAI API to OpenRouter
A developer let GitHub Copilot handle a staged switch from OpenAI API calls to OpenRouter and then checked the commit details it generated.
Have Copilot plan, patch, and open the PR for you
A developer used GitHub Copilot to shape a ticket into a plan, make the edits, and prepare the ticket and pull request after a manual check.