Nov 26, 2026 · 16 min read
Can You Test a Feature Before It Exists?
I built 15 features in a sample app, planted 58 bugs, and tested them from the spec before any code existed. A clear spec let day-0 tests cover 68% of the final suite; a vague one covered 11%. Here is what the nine labs measured, and what they can't tell you.
Most teams write tests after the feature is done. By then the spec has been bent by the code, the developer already knows the answers, and QA finds out a day late that the feature doesn't match what was asked. The idea of testing ahead is simple: write the tests from the spec while the code is still being written, so they are ready when it lands.
I wanted numbers for that idea, not opinions. So I built a lab. It has nine labs and two capstones, and it runs on a sample social app called Instaverse with 15 small features and 58 bugs I planted by hand. This post covers the nine labs and the first capstone. Two labs and the second capstone are not built yet.
Before the findings, one warning. Almost everything here is simulated. The developers, testers, bug planters and judges are AI models (Claude Code and gpt-5.4-mini), not people. The one real measurement is a tracker export from a real team, used in the first lab. Everything else runs real tests on a real app, but the roles that write and judge them are models, so the answers are about models behaving like testers. I say so each time it matters.
How I tested it
The shape of the lab is the same for most of the labs:
- Features. Fifteen features in four shapes: business rules, screens, multi-step flows, and role-based permissions. Each has a clear spec and a vague spec, written to the same standard.
- Bugs. Each feature has up to four planted bugs, for 58 in total. A planted bug is a deliberate defect inserted into a working feature. Two of the planted bugs don't build, so they are counted out, which leaves 58 that do.
- Mutants. A mutant is a small mechanical code edit, such as turning
>into>=. I used 168 of them to probe how strong a test suite is, separate from the planted bugs. - Measurement. A bug counts as caught only if the test passes on the correct build, fails on the buggy one, and fails again when rerun. That stops flaky tests from getting credit.
flowchart LR F["15 features, each with a clear and a vague spec"] --> T["Tests written from the spec"] F --> C["Code, plus 58 planted bugs"] T --> R["Run on the correct build and on each buggy build"] C --> R R --> S["Caught: fails on the bug, passes on the correct build, fails again on rerun"] class S accent
Every lab asks one question, and the answer changes what you would do on Monday.
Lab 01: Where tester time actually goes
Before I asked whether testing ahead helps, I wanted to know where the time goes now. The real data was a tracker export of 3,000 issues from one team, covering February to November 2026, with the team names anonymized. I measured the wait from "ready for QA" to the first tester picking it up.
Two causes look the same from the outside. Either the testers are busy, so work queues up (a capacity problem), or testers pick work up slowly regardless of how much is waiting (a habit problem). They need different fixes, so the lab tells them apart.
The median wait for QA was 5.2 working hours for the first team and 7.3 for the second. The third team barely waited at all. The bounce rate, where a tester sends work back, was 13% to 21% depending on the team.
The result I did not expect came from a split by queue length. For the first team, the median wait was 6 minutes when one or two items were already waiting, and 17 hours when more than ten were. But about half of its mean wait happened when nothing was queued at all. The queue explains part of the wait. The pickup habit explains the rest.
Wait by how many passes were already waiting
Waits grow with the queue, but the lowest buckets are not zero: the pickup habit adds delay even when nothing is waiting. Rank correlation between queue length and wait is 0.41 (n = 261).
The lab also tested which lever helps. Halving the time spent in QA barely moved the first team's wait, from 4.85 to 4.45 hours. Halving the pickup delay cut it to 2.68. The wait is mostly about when someone starts, not how long the testing takes.
Median wait for QA, team A (simulated)
Measured working-hour waits (95% intervals in the lab): 5.17 h (4.31–8.00), 7.25 h (5.25–9.21), 0 h (0–0.05). Halving the time in QA barely moves the wait; halving the pickup delay roughly halves it.
I also fitted a simulator to the first months and asked it to predict the last months. It passed its own trust test for the third team and failed it for the first two. The lab says that pattern fits a change in habit, but it doesn't prove one, and it's one company's data.
Lab 02: What can be tested before code
This is the core question. How much of a feature's final test suite could be written from the spec alone, before anything is built?
I had a model write the code, bugs, tests and labels for each feature. Each test was labelled by whether the spec alone justified it. The result depends heavily on the spec.
The final suite had 772 automated tests. For each one, I asked whether the spec alone said enough to write it. With a clear spec, the answer was yes for 528 of them (68%). With a vague spec, the answer was yes for only 84 (11%). The vague spec doesn't make each test harder to write. It leaves out most of the things the tests check, so the tests you could write from it are far fewer.
By feature shape: clear vs vague spec
Most of the tests a clear spec cannot justify need details the spec could have stated: error texts, response fields and the order of steps.
The tests that needed more than the spec mostly needed details the spec could have stated: error messages, response fields, and the order things happen in. That is good news, because it means the spec is the lever. You don't need a better tester. You need a spec that says what the tests will check.
On the planted bugs, the final suite caught 51 of 58 (88%). The tests written from the clear spec caught 42 (72%). The developer's own tests caught 37 (64%). On the mutants, the final suite caught 137 of 168 (82%). The gap between from-spec tests and the developer's tests was not statistically clear on its own (18 bugs only the spec tests caught, 9 only the developer's, p = 0.12), so I treat it as a direction, not a verdict.
The judge that labelled each test was checked first. The mini model agreed with the reference labels on 42 of 45 items (93%), so I used it.
Lab 03: Specs as examples
If a spec is the lever, the next question is what form the tests should take. Lab 03 turns each spec into Given/When/Then examples, binds each one to a Playwright test using the reference code (not the spec), and runs it against the 58 bugs.
I also tried a third kind of spec: the vague spec rewritten in Simplified Technical English, a controlled vocabulary used in aviation and manuals.
Clear examples caught 34 of 58 bugs (59%) from three drafts. Vague examples caught 19 (33%). The Simplified English rewrite caught 17 (29%). The clear-only catches beat the vague-only ones 19 to 4 (p < 0.01), which is the clearest difference in the lab.
The rewrite didn't help. The drafter marked 78% of its examples as guesses, and it caught no more bugs than the vague spec did. The rewrite made the spec easier to read and didn't make it more testable.
The clear examples caught fewer bugs than the from-spec tests Lab 02 wrote from the same specs (34 against 42). The lab doesn't establish why. My guess is that examples bound to the spec's own wording miss some of what the broader from-spec tests cover, but that's untested.
Lab 04: Tests before the UI
In many teams the UI is the last thing to land, so UI tests have to wait. Lab 04 asks whether they can be split in two: the intent written on day 0 from the spec, and the binding written later when the UI exists.
The critical design choice is test IDs. These are the data-testid names a team agrees on before building. With agreed IDs, 64 of 113 day-0 tests passed on the finished build. Of those 64, 46 (72%) were ready on day 0, the lab's measure of how many needed no change once the UI landed.
The IDs made UI changes less painful. When I made 30 UI changes (relabels, moves and restructures), changes without agreed IDs broke 34 tests. With agreed IDs they broke 15. The team-level version of this is the one to take away: agree the names before building, and most of your tests survive a redesign.
The day-0 UI tests caught 13 of 58 bugs with agreed IDs (22%), and 15 without them (26%). The screenshot and accessibility checks caught 3. The reason the numbers are low is that many day-0 tests never passed on the correct build. Forty-nine of 113 (43%) never passed, mostly because they assumed things that weren't true yet, such as an empty database or a route nobody had invented.
One lesson came from a stable-looking locator. A hasText match survived a relabel and also matched a wrong label, so it passed when it should have failed. Stable is not the same as strict.
Lab 05: API tests first
Backend APIs are the easiest layer to write before anything else. Lab 05 tests that directly: 144 API tests written from the spec and a machine-readable contract, run on a backend-only build the day the backend lands.
On the landing day, 85 of 144 tests passed (59%). After one fix round, where a model looked at each failure and either fixed the test or reported a backend bug, 124 passed (86%). The fix round fixed 54 tests and reported 5 backend bugs.
The bug numbers are where it gets interesting. The API tests on the landing day caught 24 of 58 bugs (41%). The UI tests on the landing day caught 15 (26%). The earliest layer that caught each bug was the API for 24 bugs, the day-0 UI for 4, and nothing at all for 7.
The API tests caught bugs that UI tests missed: data bugs, security bugs, and functional bugs. They weren't better tests. They ran on the day the backend was ready, and the UI wasn't.
There is a caveat. The fix round can "fix" a test that was catching a real bug. The lab measured that, and it is one reason I'd keep a human looking at every reported backend bug.
The timeline data also suggests when the backend is ready. Across the 13 features with a UI, the backend was done at a median of 32% of the way through the build. The backend-first order is common, but not universal.
Labs 06 and 07: Environments and risk
Two labs look at the cost of running the tests, not their coverage.
Lab 06 asks whether each pull request can get its own copy of the app, and what that costs. On this Mac, a full stack took a median of 20.4 seconds to become usable, and about 626 MiB of memory. The limit was CPU, not memory. Four stacks ran at the same time, and on a busy host the suite took more than twice as long as with one stack, which is where the lab stopped. The surprise was that the app was not ready for this at the start: the API address was hardcoded in three places, and a stack could start while its smoke test failed.
The queue model is simulated. It shows that per-PR environments pay off when a noticeable share of QA time needs a deployed build. At a 15% share, a shared staging environment's median wait was 37 working hours against 9.6 with per-PR stacks. At 5%, the gap was small. So the rule is about the share, not the tooling.
Bars are capped at 60 hours; the 20% row is 221 hours. The share is swept in the simulation, not measured. At 5% the shared environment costs about 1.5 hours; at 15% it costs about 28.
Lab 07 asks whether you can decide what to test from what a change touches. I scored each changed file for risk, using how often it changes, how many past bugs it had, and how much the tests already cover it.
The risk score was not very good. It caught escaped bugs with an AUC of 0.65, meaning that a random buggy file outranks a clean one about 65% of the time. Churn alone did better, at 0.75. The top third of files by risk held 9 of the 21 escaped bugs. That is better than chance, and worse than just looking at churn.
Testing by risk did reasonably well. In simulated hours, it caught 45 bugs for 13.75 hours of tester time. Testing everything caught 51 for 26.26 hours. Testing only what a quick look covers caught 40 for 7.5 hours. Risk gave a real saving, but not a free one. Its misses included a security bug that testing everything caught.
The regression suite I already had, 111 tests from an earlier lab, caught 5 of 58 bugs. It was never built to catch what I planted, and the lab is clear that it's not a test of the new features.
Lab 08: AI exploratory testing
The last question is whether an AI agent exploring each feature, with a browser, finds bugs the scripted tests miss. I gave a model a real browser through Playwright on a fresh stack, with three test accounts and a 60-call budget. It ran 36 times over 12 features that the scripted tests had missed 21 bugs in.
It did find some. Across three styles of prompt, the explorer's recall was 0, 1 or 2 bugs out of 21. Point-and-call, where the agent names the evidence before acting, did best, with 14% precision on planted bugs. Precision here means what share of the reports it wrote were real planted bugs.
The explorer found one real defect no test had covered: the login lockout ignored unknown email addresses. That is the honest good news, and it is a small amount of it.
The labeller, the model that decided whether a report was a real bug, was overconfident. It called 20 of 35 reports real. A simulated reviewer, reading each report against the code, called 6 real. They agreed on 19 of 35. Every explorer claim was backed by its trace, so the agent wasn't making things up, but it was still wrong about what mattered. Treat this as a second opinion that needs checking, not a replacement for a tester.
Lab 09: Fewer round trips
The last of the nine labs asks the question a team cares about most: how many times does a bug bounce between QA and development?
Two things reduce bounces. The first is checks on the pull request. If the spec's checks run before QA, they catch bugs early. They stopped 36 of 58 bugs (62%), 71% of the new behaviour and 38% of the regressions.
The second is what the bug report says. I had a model write each bug up four ways: plain, ready (numbered steps and the failing test pasted in), point-and-call, and vague (a one-line ticket). Then 60 headless Claude Code sessions tried to fix each bug from each kind of report, with the whole feature's suite as the check.
The fixes barely differed. Every form fixed 13 to 15 of 15 bugs, because each planted bug was a one-line change in readable code. That makes the form comparison a ceiling, not a finding. The useful part was the claim. Given a single sentence, the developer ran no check in any of the 15 sessions before saying "fixed". Given a failing test, it checked about three times in four.
Plain sentence
Ready report (steps + failing test)
Point-and-call
Vague one-line ticket
Every form fixed 13 to 15 of 15 bugs, so the fix rate is a ceiling. The gap that matters is the check: with a failing test attached, the developer checked its own fix far more often.
The simulated round trips show the scale. For the first team, round trips per issue fell from 0.151 to 0.057 with the pull request checks, and to 0.054 with the ready report too. The check did most of the work. The report changed very little.
Capstone A: putting it together
The first capstone takes the results from labs 02 to 05 and compares four ways of testing the same features:
| Flow | Ready at merge | Caught before QA (of 58) | Caught at all (of 58) |
|---|---|---|---|
| Testing after | written after merge | 0 | 51 (88%) |
| Developer's own tests | 82% | 37 (64%) | 37 (64%) |
| Test-ahead, clear spec | 84% | 37 (64%) | 37 (64%) |
| Test-ahead, vague spec | 81% | 19 (33%) | 19 (33%) |
| Developer's tests plus test-ahead (clear) | 83% | 40 (69%) | 40 (69%) |
Each bar is one suite or layer written from a different source, on the same 58 bugs. Simulated: the test writers were AI models. The lab’s 95% intervals are about ±12 points, so small gaps are not meaningful.
Test-ahead from a clear spec matched the developer's own tests on bugs caught before QA. It did not beat them. Testing after the feature still caught more bugs in the end (14 bugs only it caught, and none only test-ahead caught). The point of test-ahead is not a better catch rate. It is that the tests are ready when the code lands, and the questions they raise come out during the spec, not the bug report.
The capstone's report is built by a script, and the continuous integration runs it. A claim guard fails the build if a number in a claim doesn't match the table it cites. The guard checks that the claims agree with the tables. It does not re-check the lab results themselves, so it's only as good as the labs under it. The report also rebuilds byte for byte from the committed results.
What this doesn't prove
- The roles are models. Every developer, tester, planter, labeller and judge was an AI model. Real teams would have different blind spots, and real testers would catch different things.
- One app, 15 features, 58 bugs. With that few bugs, the intervals are wide. The capstone's own numbers are about ±12 points.
- My bugs are not your bugs. I planted them. Real bugs come from real mistakes in real code, and some of mine were close to the spec's own wording.
- The spec is written by me. The clear and vague specs were written to a standard I set. A real team's vague spec may be vaguer, or clearer in different places.
- No screenshots or videos. The labs tested failing tests in reports, not screenshots, videos or step lists. The handover section is my experience, not a measured result.
- One company's data. The only real measurement, the wait for QA, came from one team's tracker. The simulator fitted to it did not predict every team's quiet period.
What a useful handover looks like
The labs measured one thing about handover: a failing test attached to the report. They didn't measure screenshots, videos or step lists. But one pattern from my own experience matches what the labs found, so it's worth saying plainly.
The best handovers I have received came from a developer who ran the happy path before passing the work on. Not just generated the feature, but clicked through it. The evidence was specific: the steps they took, a screenshot of the result, sometimes a short video. That tells the tester three things: the feature runs, here is how the developer exercised it, and here is where the tester can start writing automation without guessing the flow.
flowchart LR
A["Developer prompts the model"] --> B{"Runs the happy path?"}
B -- "No" --> C["Hands over code"]
C --> D["Tester guesses the flow and finds the first bug"]
B -- "Yes" --> E["Attaches steps, screenshot or video"]
E --> F["Tester starts from a known-working flow"]
class F accent
class D warn
Two things make this useful. The evidence shows the developer ran the tests, not just the prompt. And it gives the tester a known-good path to build from, which is the same thing the lab's ready-made report did when it included the failing test verbatim.
What I'd do
Based on what the labs measured, this is what I'd try first:
- Spend the time on the spec before the code. The spec is the lever. A clear spec supported 68% of the final suite on day 0, and a vague one 11%. Ask what the tests will check, and write down the error messages, response fields and order of steps.
- Agree on test IDs before the UI is built. Agreed IDs kept more tests alive through a redesign (15 tests broken against 34) and left 72% of the day-0 UI tests that passed on the finished build ready on day 0.
- Write API tests the day the backend lands. They caught 24 bugs that landing day, against 15 for the UI tests on the same day. Keep a person reading every backend bug the fix round reports.
- Only build per-PR environments when QA waits on deployed builds. The lab's simulated queue says the payoff starts when a noticeable share of QA time needs a build, not from the first PR.
- Be careful with risk scores. A simple churn number beat my risk score. Use risk to pick what to test first, not to decide what never gets tested.
- Don't let an AI explorer report unchecked bugs. It found one real defect in 36 runs, and its own labeller overcounted real bugs about threefold. Use it as a second pair of eyes that someone reviews.
- Attach the failing test to every bug report. It made the developer check its fix three times in four, against never with a sentence alone.
The labs are not finished. Labs 10 and 11 (shipping dark behind flags, and a feature nobody planted) and the second capstone (the full test-ahead process) are still to build. When they are done, I'll write the next post.