The agent said "done." The tests disagreed.
That's the moment that matters. Not the moment the agent stops typing — the moment something deterministic checks its work and either confirms or contradicts the claim. A test suite is how an agent (and, honestly, how I) get high-fidelity context on the actual state of a codebase after a change. It's the same reason a pull request runs CI and the same reason a new hire runs the test suite locally before claiming a ticket is finished. Tests aren't a checkbox at the end of the process. They're the eyes an agent doesn't otherwise have.
I've spent the last year using GitHub Copilot across Visual Studio, VS Code, and the Copilot coding agent, on a TypeScript video pipeline (vidpipe) and on client work that's mostly .NET. This article is the reference I wish I'd had: what Copilot's testing surfaces actually do today, which parts are generation versus review, where coverage lies to you, and the one piece of infrastructure — deterministic, hook-enforced spec-to-test-to-code gating — that's made my own repo nearly immune to technical debt. Not immune to bad decisions, and not a literal 100%-of-every-line guarantee — the gate runs on a configurable coverage threshold, not perfection. But it closes the gap between what the code does and what the tests prove it does, by construction, on every commit.
Stop Vibe Coding Features — Build the Maintenance Architecture First
The first mistake I see teams make with Copilot and testing is treating it as a feature-generation tool first and a testing tool second, if at all. That ordering is backwards.
If you let an agent generate features into a repo that has no test framework, no architectural boundaries, and no CI gate, you get a pile of code that looks finished because the agent said so — confidently, in complete sentences — and has no independent mechanism to check. That's exactly the failure mode I wrote about in vibe testing: when AI agents Goodhart your test suite: an agent optimizing for "tests pass" will, left unchecked, write tests that are trivially easy to pass rather than tests that are hard to pass and meaningful. The fix isn't "write more tests." It's "stop letting the agent build without the scaffolding that keeps it honest."
So before I ask Copilot to generate a single feature, I ask it to generate (or verify) the maintenance architecture:
- A test framework per test tier — unit, integration, UI/E2E — already wired into the build, with a single command to run each tier.
- Architectural layer boundaries that are checked, not just documented in a README nobody reads.
- A CI pipeline that fails loudly when tests don't exist or don't pass.
- Custom instructions that make "write tests" the default behavior rather than a thing you have to remember to ask for.
This is the same argument I made in auditing a codebase for AI testability: before you turn an agent loose on a codebase, audit whether the codebase can actually tell the agent when it's wrong. If it can't, you're not accelerating development — you're accelerating the rate at which undetected bugs accumulate. Agent-proof architecture is built in layers for a reason: instructions guide intent, hooks catch mistakes in real time, gates block bad changes permanently, and a sandbox limits blast radius. Testing infrastructure is the gate layer. Skip it, and every other layer is advisory.
Make Tests the Default, Not a Request
Once the scaffolding exists, the next lever is making "write tests" something Copilot does by default instead of something you have to ask for every single time.
GitHub Copilot supports repository-wide custom instructions in .github/copilot-instructions.md, plus path-scoped instructions in .github/instructions/*.instructions.md with an applyTo glob. GitHub's own guidance suggests rules as direct as "write unit tests for new functionality" — and critically, Copilot code review honors these same instruction files, reading them from the pull request's head branch. That means the same instruction that nudges the agent to write a test while it's coding also becomes the rule the automated reviewer checks the PR against afterward. One file, two enforcement points.
In vidpipe, this isn't a single blanket instruction — it's a dedicated specs.instructions.md with path-specific rules, because "write tests" is too vague to be useful at the point an agent is deciding what a test should assert. The more specific the instruction (which tier, which boundary, which naming convention for traceability), the less the agent has to guess, and the less a reviewer has to catch after the fact.
This is a cheap, high-leverage move most teams skip. If your repo doesn't yet have a .github/instructions/*.instructions.md file scoped to test files, that's step one — not a nice-to-have.
The Verified Copilot Testing Toolbox
Here's the part I had to actually research rather than assume, because the Copilot testing surface is scattered across four different products with four different levels of maturity. I'm not going to describe a feature that doesn't exist — if something is experimental or doesn't exist, I'll say so.
| Surface | Test type | What it actually does | Maturity (as of this writing) |
|---|---|---|---|
Visual Studio @Test agent |
Unit, integration (.NET) | Scopes to member, class, file, project, solution, or #git_changes; generates, builds, runs, fixes failing tests, and reports before/after coverage |
GA since VS 2026 v18.3 |
| VS Code Agent mode + guides | Unit, integration | No dedicated test agent — Agent mode plus two official guides, "Test existing code with AI" and "Practice test-driven development with AI"; Test Explorer has a "Fix Test Failure" action; /setupTests is explicitly labeled Experimental in the docs |
Mixed — core workflow documented, test scaffolding experimental |
| Copilot coding agent | Unit, integration, UI (ad hoc) | Runs in an ephemeral GitHub Actions environment set up by copilot-setup-steps.yml; Playwright MCP tools are available by default for browser interaction; can run tests/linters when useful but does not guarantee a full-suite run before opening a PR |
GA, CI remains the real gate |
| Playwright Test Agents | UI/E2E | Three roles — planner (explores the app, writes a Markdown test plan), generator (turns the plan into Playwright tests), healer (fixes failing tests against the live app) | Stable since Playwright v1.56, current in v1.65+ |
Visual Studio @Profiler agent |
Microbenchmarks | Analyzes CPU/memory, finds hot paths, and can generate or tune BenchmarkDotNet benchmarks, then validates the improvement | Requires VS 2022 17.14+ |
| Azure Load Testing VS Code extension | Load testing | Uses Copilot to author Locust or JMeter scripts from Postman collections, Insomnia exports, or .http files, then runs them locally and at scale in Azure |
GA — not k6 |
Two honest gaps in that table: VS Code genuinely has no named "test agent" the way Visual Studio does, and there is no unified Copilot load-testing agent anywhere in the ecosystem. If you see a blog post claiming otherwise, it's describing a workflow someone built around Copilot, not a shipped feature. I'd rather tell you the gap exists than have you go looking for a button that isn't there.

Unit/integration, UI automation, and performance tests each answer a different question. Each one also uses different Copilot tooling and a different pass criterion.
Also worth noting: Visual Studio's @Test agent is one of several specialized, built-in agents — alongside @debugger, @profiler, and @modernize — which I covered in more depth in my GitHub Copilot in Visual Studio guide.
Coverage Is a Metric, Not a Goal
Every team that adopts AI-assisted testing eventually puts a coverage percentage in a dashboard. That's fine as a diagnostic. It's dangerous as a target.
Here's why: coverage tells you a line of code executed during a test run. It does not tell you the test asserted anything meaningful about what that line produced. An agent chasing a coverage number will happily write a test that calls a function, touches every branch, and asserts nothing — or asserts something trivial, like "the function didn't throw." Coverage goes up. Confidence should not.
I treat coverage the way Martin Fowler describes it in TestCoverage: a useful signal for finding code nobody is exercising at all, and a genuinely bad target to optimize directly, because optimizing a proxy metric degrades the thing it was supposed to measure. The way I actually use it:
- As a diagnostic: which files, functions, or branches have zero coverage? That's a worklist, not a dashboard.
- As a changed-line gate: did the lines you just changed get exercised by a test, specifically? This is a much narrower, much more honest question than "what's the repo's overall percentage," and it's the one that's actually enforceable at commit time (more on this shortly).
- Never as a universal target like "80% coverage across the board." That number invites exactly the gaming behavior it was meant to prevent.
If you want the deeper argument for treating coverage as a lagging indicator rather than a goal, I made the full case in tests are everything in agentic AI — the short version is that the suite's job is to be a cheap, fast, repeatable proxy for "does this still work," and a metric that's easy to game stops being a reliable proxy the moment anyone — human or agent — starts optimizing for it directly.
Boundaries Define What You Mock
Here's a question that sounds simple and usually isn't: what's the difference between a unit test and an integration test? Most teams answer with vibes. I answer with an enforced rule: it's where you mock, not how you feel about the test.
In vidpipe, I organize the codebase into layers, L0 through L7, with a strict rule: a layer can only import from layers below it, never sideways or up. L0 is isolated — no Node built-ins, no dependencies on anything else in the tree. Higher layers are permitted a progressively wider import surface as you go up the stack. This isn't a convention in a wiki page; it's enforced by a Copilot CLI hook (pre-layer-import) that runs on every tool call during an agent session and blocks an edit that would violate the boundary.
The mocking rule follows the same logic, enforced by a second hook (pre-layer-mock): a unit test is expected to mock only the layer directly below the thing it's testing, not layers further down or sideways concerns. L0 units get essentially zero mocks — there's nothing beneath them to fake. Integration tests get looser, per-workspace mocking rules, because their job is to verify two or three real layers cooperating. End-to-end tests are meant to run with the fewest mocks of any tier, because the entire point of an E2E test is that as little as possible is faked.
That one rule answers the "what's a unit test vs. integration test" question definitively, every time, for every PR, without a human having to adjudicate it: a unit test that reaches two layers down to mock something is wrong, by definition, and the hook tells the agent so immediately instead of waiting for a reviewer to notice three days later.

Imports flow down only, and a unit test mocks only the layer directly below it. The pre-layer-import and pre-layer-mock hooks enforce both rules during the agent session.
If you're not working in TypeScript, the enforcement tools differ but the principle doesn't: dependency-cruiser and eslint-plugin-boundaries do this for JS/TS, ArchUnit does it for Java/Kotlin, and NetArchTest does it for .NET. Pick one, wire it into CI (and ideally into your agent's hook layer if your harness supports pre-commit enforcement), and the unit/integration/E2E question stops being a style debate.
Assertions or It Didn't Happen: The Deterministic Floor
Layer boundaries tell you what a test is allowed to touch. They don't tell you whether the test actually checked anything. For that, you need a second, much blunter deterministic gate: does this test assert at all, and does it assert enough?
A test with zero assertions that still passes is worse than no test — it's a false signal of safety. This is a known enough failure mode that tooling exists specifically to catch it: eslint-plugin-jest's expect-expect rule flags test blocks with no expect() call, and SonarQube ships an equivalent rule for assertion-free tests across more languages. Wire one of these into your lint step and an agent literally cannot commit a test that asserts nothing — the commit gate fails before a human ever has to notice.
This is a floor, not a ceiling. It catches "no assertions" and "suspiciously few assertions." It cannot tell you whether the assertion that is present is actually checking the right thing. For that, you need judgment — which is exactly where coverage-counting tools and assert-counting tools both run out of road, and where the next section picks up.
If you want a stronger deterministic proxy for assertion strength than a raw count, mutation testing (Stryker, for JS/TS/.NET) deliberately corrupts your production code in small ways and checks whether your suite notices. A test suite that still passes after the mutant is introduced wasn't actually testing the thing it claimed to test. It's slower to run than a coverage report, which is why I treat it as a periodic deep-check rather than a per-commit gate — but it's the closest thing to a deterministic answer to "are these assertions actually doing anything."
Agentic Test Review: Two Dimensions, Judged Separately
This is the part of my own process I want to be honest about, because it's a recommendation, not something I run continuously today.
Deterministic gates — layer boundaries, assert-count checks, changed-line coverage — are necessary but not sufficient. They can tell you a test exists, touches the right layer, and contains assertions. They cannot tell you whether those assertions are any good. For that, you need a reviewer with judgment, which today means an agentic (non-deterministic) review pass, scored on two separate dimensions:
Dimension 1 — Coverage. Is the new or changed behavior exercised by any test at all? This dimension leans heavily on the deterministic coverage diff as its input signal — an agentic reviewer doesn't need to re-derive what a coverage tool already computed precisely.
Dimension 2 — Assertion quality. Does each assertion validate actual behavior, or does it merely detect that something changed? This is the dimension no deterministic tool can fully judge, because it requires understanding intent.
Here's the distinction with the examples that make it concrete:
- Weak — asserting that a rendered paragraph of text contains a specific sentence. That assertion tells you the text is different from some expected string. It doesn't tell you the text is correct. It's a change-detector: useful for catching accidental regressions in a literal string, useless for catching a logic bug that happens to produce text that still contains the sentence.
- Strong — "if this action is performed, the result should be X." That assertion validates the actual behavior the code is supposed to produce, independent of incidental details like exact wording.
A deterministic assert-count gate can't tell these apart — both examples have exactly one assertion, and both pass lint. Only a reviewer that understands what the code is supposed to do can flag the weak one as change-detection masquerading as a test.
The two gates are complementary layers, not a replacement for each other: assert-count is a cheap, deterministic quantity floor; agentic review is an expensive, judgment-based quality check. You still want both — the assert-count gate stops the worst case (zero assertions) for free on every single commit, while the agentic quality review catches the subtler case (assertions that exist but don't mean anything) on a slower cadence.
Where would this actually run, if I built it? Two realistic surfaces, both already verified to exist:
-
Copilot code review, with test-quality rules added to a path-scoped
.github/instructions/*.instructions.mdfile targeting test globs. Since code review reads instructions from the PR's head branch, a rule like "flag assertions that only check for the presence of a substring without validating the underlying computed value" becomes part of what the automated reviewer looks for on every PR — an advisory signal, not a hard merge block on its own. - A scheduled GitHub Agentic Workflow via GitHub Next's Continuous AI program, which already ships a sample "Test Improver" workflow that runs daily and opens pull requests that improve test coverage where it matters — the same infrastructure that could host a periodic assertion-quality audit rather than (or in addition to) a coverage-improvement pass.
To be direct about where I am today: I run the deterministic floor on every commit. I don't yet run a continuous agentic quality pass. This section is the recommendation, not the status report.
Agentic for Discovery, Deterministic for the Gate
This is the story that ties everything above together, and it's the one piece of this article I went back and independently verified against the live repository rather than describing from memory — because the actual mechanism turned out to be more specific, and more interesting, than my own working description of it.
vidpipe is my open-source video pipeline project. It has a .github/hooks/ directory that fires live, during a Copilot CLI agent session, on every tool call the agent makes. These are real-time, pattern-based guardrails — fast and heuristic, by design:
-
pre-commit-blockandpre-push-blockdeny rawgit commitandgit pushoutright, forcing every change throughnpm run commitandnpm run pushinstead. (There's alsopre-amend-blockandpre-force-push-blockfor the obvious escape hatches.) -
pre-layer-importenforces the L0–L7 downward-only import matrix described above, in real time, as the agent edits files. -
pre-layer-mockenforces the layer-directly-below mocking rule described above. -
pre-reexport-blockstops a layer from laundering a forbidden import through a re-export. -
spec-governance.mjs, run as aprehook, checks the staged diff for any addedREQ-###requirement row in aspecs/**/*.mdfile and requires a matching{SpecName}.REQ-###reference somewhere in the staged test diff. No matching reference, no commit. A companionposthook fires after a spec edit purely as a reminder to go update the corresponding test. -
post-edit-invalidatedeletes areviewed.mdmarker file on any code edit, invalidating a prior review state so stale approvals can't linger.
Those hooks are the agentic-for-discovery layer: fast, in-session, and focused on steering behavior while the agent is actively working. But here's the part I hadn't fully internalized until I went and read the actual code in cicd/lib/commitGate.ts and cicd/lib/coverageChecker.ts: the hooks don't themselves compute coverage or run the test suite. They exist specifically to force every commit through npm run commit, where the real, authoritative, deterministic gate lives.

Fast, heuristic session hooks steer the agent while it works. The slower npm run commit gate decides what becomes permanent.
That gate runs a seven-step pipeline on every attempted commit:
- Classify every staged file by architectural layer, test tier, spec-file status, or exempt status.
- Typecheck any type-only changes.
- Re-validate the entire L0–L7 layer-boundary matrix across the whole
src/tree — not just the staged files, the whole tree, because a boundary violation introduced three commits ago and missed is still a violation. - Re-check spec-to-test traceability (the same
REQ-###concept the hook checks, enforced again, authoritatively, against the full staged diff). - Validate that each changed layer has its required test tiers represented among the staged test changes — a change to an L3 module without any L3-tier test present fails here, independent of coverage numbers.
- Actually execute the relevant tests, with coverage instrumentation turned on.
- Map the git diff's added and changed line ranges onto the Istanbul/v8 statement coverage map, and compute, per changed file, what percentage of its changed, executable lines — not blank lines, not comments — were hit by at least one passing test. A file passes once that percentage meets or exceeds a configurable threshold (80% by default); it does not require literally every changed line to be covered.
There's an explicit --skip-coverage escape hatch, and it's logged every time it's used, specifically because it's meant for genuine emergencies, not routine convenience.
That's the mechanism, verified against the live 9660a8b commit of the repository rather than assumed: agentic hooks catch bad patterns fast while the agent is still working, but the actual enforcement authority is a slower, more thorough gate that runs the real tests and checks real coverage against the real diff before git commit is ever invoked. "Agentic for discovery, deterministic for the gate" isn't just a nice phrase — it's a literal description of two separate systems with two separate jobs, one fast and heuristic, one slow and authoritative.
The result, in practice: the repository is nearly immune to technical debt. Changes can't land without matching tests, without respecting architectural boundaries, and without clearing the configured coverage threshold on the lines that changed. It's a threshold, not perfection — the gate doesn't require every single line to be hit, and there's a logged --skip-coverage escape hatch for genuine emergencies — but the default bar is high enough, and checked on every commit, that debt can't quietly accumulate the way it does in a repo with no gate at all. What can still happen — and does — is product-alignment debt: a feature that's fully tested, adequately covered, architecturally clean, and still not what the product should actually do. The gate verifies the code does what the spec says. It can't verify the spec says the right thing. That's a human (or at least a slower, more deliberate agentic) judgment call, and no hook I've built catches it.
This is also, not coincidentally, the practical implementation of an idea I'd already written about before I built the enforcement for it. I argued that specs equal tests back when it was still mostly a philosophy, and I sketched "the vision: specs → tests → code" in agent-proof architecture before vidpipe's hooks existed to enforce it. The line-level coverage mechanism itself lines up with what I described in test-enforcement architecture for AI agents — a hook that analyzes exactly which lines changed and verifies tests specifically cover those lines, not just "some test somewhere passed." Writing about the pattern came first. Watching the live code confirm it, months later, is the satisfying part.
If you want to try this yourself without building the full pipeline first, here's the prompt pattern I use to convert an agent's exploratory work into something deterministic and permanent: "Before ending this session, write a deterministic test that reproduces the validation you just performed, commit it, and confirm it fails when the behavior regresses." The agent did the expensive, non-deterministic work of figuring out how to verify something. The test it leaves behind is cheap, deterministic, and runs forever without burning another token.
Performance Testing Is Not UI Automation
I want to correct something I used to believe, because I suspect a lot of readers believe the same thing: performance testing is not just UI automation run at a larger scale. Both are "a script that runs," but they answer fundamentally different questions, and treating one as a substitute for the other will give you false confidence in exactly the dimension you actually care about.
UI/E2E testing asks: can a small number of real browsers complete a specific user journey correctly? The pass/fail criterion is functional and largely deterministic — the checkout flow either completes or it doesn't. You're running few, heavy browser instances, and correctness, not throughput, is the point.
Load testing asks an entirely different question: can the system sustain a modeled workload within its service-level objectives? This is usually driven by cheap, protocol/HTTP-level virtual users specifically because you need to scale them into the thousands, which a real browser instance can't do economically. Pass/fail comes from statistical thresholds — p95/p99 latency, error rate, throughput — not a single deterministic assertion, which is also why a load test needs a stable, representative environment and a baseline run to compare against. A single noisy run tells you nothing; a trend does. k6's documentation treats thresholds as first-class citizens for exactly this reason, and even separates browser-level metrics from protocol-level metrics because they measure different things.
Microbenchmarks are a third category entirely, distinct from both. Tools like BenchmarkDotNet time individual methods, run many iterations to get statistically meaningful results, and tell you whether a specific function got faster or slower — not whether a user journey works, and not whether the system holds up under concurrent load.
So: a UI suite run at higher concurrency is a poor load test, because browser automation doesn't model realistic concurrent load the way protocol-level virtual users do, and it tells you nothing about p95 latency under sustained traffic. A load test, in turn, doesn't validate that the user journey is correct — it only validates that the system stays responsive while something is happening. You need both, and they're not interchangeable.
Where does Copilot actually fit? As an author, not an executor of the regression gate itself:
- The Azure Load Testing VS Code extension uses Copilot to generate Locust or JMeter scripts from Postman collections, Insomnia exports, or
.httpfiles, then runs them locally first and at scale in Azure afterward. It's documented around those two frameworks — not k6. - Visual Studio's
@Profileragent can generate or tune BenchmarkDotNet benchmarks after identifying a hot path, which is the microbenchmark lane, not the load-test lane. - Generic Agent mode or the coding agent can draft a k6 script or a BenchmarkDotNet class the same way it drafts any other code — useful, but it's authoring help, not a dedicated feature.
The deterministic gate for performance isn't a single exact-value assertion the way a unit test is. It's a threshold or budget checked in CI — "p95 under 300ms," "error rate under 0.1%," "this method allocates under 2KB" — and Copilot's job is to help you author the script that measures against that budget, not to own the pass/fail decision itself. Agentic exploration (profiling, finding the hot path) converts into a deterministic benchmark or threshold the same way agentic test discovery converts into a deterministic unit test: the expensive judgment work happens once, and the cheap, repeatable check runs forever afterward.
Continuous Test Quality
Put the pieces together and you get a pipeline with three distinct speeds, each catching something the others can't:
- Real-time hooks (seconds) — pattern-based, catch obviously bad moves while the agent is still working: raw git commands, layer-boundary violations, mocking the wrong layer, a spec requirement added without a matching test reference.
- Commit/CI gates (minutes) — deterministic, authoritative: full layer re-validation across the tree, spec-to-test traceability, required test tiers per layer, actual test execution, and changed-line coverage against a threshold. This is where "it compiles and the agent said it works" becomes "the tests that cover exactly what changed actually pass."
- Periodic agentic review (hours to days, scheduled) — judgment-based, catches what the first two can't: assertion quality, change-detection masquerading as logic validation, and — via GitHub Next's Continuous AI sample workflows like the daily Test Improver — opening PRs that improve coverage where it actually matters rather than wherever is easiest.
That three-speed structure is the Continuous AI idea applied specifically to testing, and it's the same shape I laid out more generally in the complete guide to agentic development in DevOps: fast heuristics for real-time steering, slower deterministic gates for authoritative enforcement, and scheduled agentic passes for the judgment calls that don't fit a regex. Each layer runs at the speed its job requires, and none of them tries to do the other layers' jobs.
The Checklist
If you're setting this up this week, in order of leverage:
-
Instructions first. Add a
.github/instructions/*.instructions.mdscoped to test files with a concrete, specific rule — not "write tests," but "unit tests for this layer may only mock the layer directly below." - Frameworks before features. Confirm a runnable test command exists for every tier you care about (unit, integration, UI) before asking Copilot to build anything new.
- Boundaries that are checked, not documented. Pick a tool for your stack — dependency-cruiser, eslint-plugin-boundaries, ArchUnit, NetArchTest — and wire it into CI so "what's a unit test" stops being a debate.
-
A deterministic assert-count gate.
expect-expector SonarQube's equivalent rule, whichever fits your linter. Free, immediate, catches the worst case on every commit. - A changed-line coverage ratchet, not a global percentage target. Gate on whether the lines you just touched are covered, not on whether the whole repo hit an arbitrary number.
- Agentic test-quality review, scheduled, not continuous. Start with Copilot code review instructions targeting assertion quality; graduate to a scheduled Continuous AI workflow once you trust the rubric.
- Performance budgets, explicitly separated from UI tests. Decide your p95/error-rate thresholds and your microbenchmark baselines before you ask Copilot to author the scripts that check them.
None of this requires waiting for a vendor to ship a unified "AI testing feature." The deterministic layer is tooling you can wire in today, in an afternoon, in any stack. The agentic layer — generation and quality review — is Copilot doing what it's actually good at: exploring, drafting, and judging. The gate is what makes the exploration permanent instead of just a claim.
Tests are your agent's eyes. Give it good ones, and gate what it sees with something that can't be talked out of the truth.
Top comments (0)