Skip to main content
[research]

Coding Agents Write More Tests. But Can We Trust Them?

We evaluated three coding agents on 240 open source projects. Their test suites beat human ones on aggregate coverage, but they scale poorly to larger projects, win mostly by brute force, and are unfaithful translators of tests.

Three charts comparing test suites written by Claude Code, Cursor, Codex and humans. (a) Mutation score, the share of injected bugs each suite catches: Claude 0.82, Cursor 0.78, Codex 0.72, Human 0.63. (b) Share of vacuous tests that still pass with the code stubbed out, by language, from 0.04 to 0.15 across Python, C++ and Rust. (c) Spend per mutant killed relative to Codex: Claude costs 7.3x the input tokens, 6.4x the output tokens and 8.5x the wall-clock time; Cursor costs 2.3x, 3.6x and 4.7x.

Coding agents are an essential cog in the modern software development pipeline, increasingly trusted with tasks as ambitious as generating codebases and transpiling (translating) them from one language to another. However, as reliance on generated code increases rapidly, so does the value of assurance that this code actually works.

Traditionally, the workhorse of assurance has been unit and integration testing. Developers write comprehensive test suites, iterating against them until the suite passes and they are reasonably confident that their code obeys a set of desired properties. In many modern workflows, however, developers also rely on agents to formulate such tests. In this work, we test the ability of modern agentic setups to write these tests, constructing a benchmark of open source projects across three different programming languages (Python, C++, and Rust) and three size tiers.

Leveraging both traditional software-testing metrics and custom measurements, our results reveal a tension between the aggregate picture and granular analysis: while agents exceed human test suites in traditional coverage metrics, they often scale poorly to larger projects and achieve higher coverage primarily by writing larger numbers of tests. We also find that agents frequently fail to preserve testing capabilities when transpiling tests from C++ to Rust.

Overview of the two tasks. Task 1, agentic unit test generation: Python, Rust and C++ projects (30 small, 30 medium and 20 large each) go to Cursor, Claude Code and Codex, which generate tests that are then scored; 3 agents by 3 languages by 80 projects. Task 2, transpilation plus test generation: C++ projects are transpiled to Rust, the agents generate Rust tests, and the tests are scored.

The Benchmark

To measure the ability of modern agentic setups to generate tests in diverse contexts, we extract 240 permissively licensed GitHub projects with passing test suites. The dataset consists of 80 projects in each of three languages: Python, C++, and Rust. Projects within each language are also stratified by size: 30 small projects (under 1,000 lines of source code), 30 medium (1k to 5k) and 20 large (5k to 10k).

We run two experiments on the resulting dataset:

  • Test generation. We delete the human tests and ask each agent to write a test suite from scratch. The agent can build the project, run its tests and read the output. We evaluate three agents with their native models at high reasoning effort: Claude Code (Claude Opus 5), Codex (GPT-5.6 Sol) and Cursor (Cursor Grok 4.6).
  • Test transpilation. We transpile 50 projects from C++ to Rust, and prompt the agents to translate the corresponding test suites. Each agent gets the C++ project, its C++ tests and the Rust source as context. As a control, we also ask Codex to write a test suite using the Rust source alone.

All agentic measurements are means across three generations per project.

Scoring

We leverage a suite of metrics to evaluate how thoroughly the human and agent test suites cover the source code. All test suites are scored against traditional software testing metrics, in combination with several new metrics we define ourselves.

MetricWhat it measuresMethodology
Line coverageHow much of the code does the suite run?Share of production lines executed by tests
Mutation scoreHow effectively does the suite detect bugs?We inject up to 120 small bugs per project (flip a comparison, swap + and −, change a constant). The mutation score is the share of compiling mutants that make some test fail, hang or crash
Vacuous-test rateDo the tests check anything at all?Replace every public function body with a do-nothing stub. Share of tests that still pass
Behavioral coverageAre the nontrivial public behaviors tested?An LLM judge lists each project’s nontrivial public functions; share of that list the suite exercises
Edge-case coverageAre edge case inputs tested?The same LLM judge model drafts edge case input conditions for these public functions; share the test suite reaches. Edge cases include malformed inputs and values exceeding boundaries.

The first two metrics listed are classic software-testing metrics. They tell us whether tests execute the code and catch simple faults, but not whether they cover core public functions or check how the code handles invalid and edge-case inputs. The judge-based metrics fill this gap, scoring human and agentic test suites against a consistent set of behaviors and edge cases. We also track several other performance and cost metrics, including branch coverage, assertion count, token usage, tool calls and wall-clock time.

Agents beat human suites, but scale worse on larger projects

Averaged over all 240 projects, every agent beats the human suites. Mutation scores are 0.82 for Claude Code, 0.78 for Cursor and 0.72 for Codex, against 0.63 for the human tests. Mutation scores with corresponding confidence intervals are plotted in plot a below.

Averaged across the three agents, the lead over the human suite is 0.15 in mutation score, 0.14 in line coverage, 0.27 in behavioral coverage and 0.35 in edge-case coverage. All gaps are significant when using a paired t-test with p=0.05.

Two charts. (a) Mutation score by author, with error bars: Claude 0.82, Cursor 0.78, Codex 0.72, Human 0.63. (b) Mutation score by project size from small to large: every author declines, Claude by 0.11, Cursor by 0.21, Human by 0.11 and Codex by 0.29, so on large projects Codex falls just below the human suites.

The agentic lead is not uniform. It roughly halves from small to large projects, and on large projects Codex (0.55) drops slightly below the human suites (0.57). The programming language tested is also an important factor: mutation scores for all agents are at least 14% lower in C++ than they are in Python.

Agents win by volume, not by sharper tests

While agent generated test suites achieve higher aggregate results, this advantage does not necessarily extend to individual tests. On a per-test basis, human tests cover more lines than two of the three agents. A human test covers 8.5 unique production lines on average, against 3.7 for Cursor and just 2.2 for Claude Code.

Three charts. (a) Production lines covered per test written, median project: Claude 2.2, Cursor 3.7, Codex 11.6, Human 8.5. (b) Vacuous test rate by language: Python 0.10 Claude, 0.07 Cursor, 0.04 Codex; C++ 0.14, 0.15 and 0.08; Rust 0.15, 0.14 and 0.11. (c) Spend per mutant killed relative to Codex: Claude 7.3x input tokens, 6.4x output tokens and 8.5x wall-clock time; Cursor 2.3x, 3.6x and 4.7x.

Claude Code reaches the top mutation score largely by writing a plethora of tests. This approach comes at a steep price. Per mutant killed, Claude Code spends 7.3× the input tokens, 6.4× the output tokens and 8.5× the wall-clock time of Codex. Some of the volume is also hollow: the vacuous-test rate (tests that still pass when the function they target is stubbed out) is highest for Claude Code overall, and increases sharply for C++ and Rust projects.

Agents are unfaithful translators of tests

In aggregate, test transpilation from C++ to Rust seems acceptable. The original C++ suites reach a mean mutation score of 0.56; the translated Rust suites reach 0.51 (Claude Code), 0.49 (Codex) and 0.51 (Cursor). Line coverage drops more, from 0.75 to between 0.61 and 0.65, but could potentially be accounted for by code length and measurement differences across languages.

Dot plot of edge case coverage for each C++ project, sorted by the C++ source suite's score. The translated Rust suites from Claude Opus 5, Codex GPT-5.6 and Cursor Grok 4.6 cluster together and often fall below the source suite, while the free-form Rust suites written without the C++ tests usually score higher.
Each column is one C++ project, sorted by the human suite’s edge case coverage (black). Filled dots are the translated Rust suites; open squares are Rust suites written without the C++ tests.

The case-by-case comparison, however, is far worse. The translated suite kills fewer mutants than its C++ source in 55% of projects, and covers fewer edge cases 58% of the time, with a mean relative reduction of 16% for non-zero suites. In one extreme instance every agent loses close to 70% of the source suite’s mutation score.

The control, where the Rust suite was written based on source code alone, almost always scores at least as high as the translated tests. The agents seem to interpolate between translating and writing fresh tests: where free-form generation is strong, the translation can beat its source; where it is weak, the translation is often weak too, sometimes falling below both the free-form suite and the human original.

Dot plot of raw mutation scores for each C++ project, sorted by the human suite's score. The three agents' translated Rust suites sit close together on most projects, often below the C++ human suite, while the free-form Rust suites mostly score at or above them.

The three agents’ translated suites cluster tightly on most projects. This points to a property of the task rather than a weakness of one particular model or harness.

Why it happens

To better understand observed testing failures, we examine the agents’ reasoning traces. We analyze 675 Codex test-generation trajectories (three runs on each of 225 projects), tracing weak suites back to their root causes. Three recurring failure modes emerge:

  • Scope: the agent never reads relevant source files, or decides to skip a behavior it has already found (15% of trajectories).
  • Oracles: the agent keeps an assertion it knows is wrong, or weakens one until it passes (11%).
  • Feedback: the agent never measures coverage at all, and only checks that its tests pass (56%).

The full paper walks through these traces, and tests a prompt that warns the agent about these failure modes, yielding measurable gains.

Conclusion and what’s next

Our findings suggest that generated and transpiled suites lacking formal verification should continue to be treated as drafts. Reviewing them and measuring them with metrics beyond pass rate remains essential; all suites measured in our benchmark passed, yet drastically varied in quality.

The paper, “Can Coding Agents Write and Transpile Unit Tests?”, appears at the NeurIPS 2026 workshop “Who Verifies the Agents?”

Read the full paper: Can Coding Agents Write and Transpile Unit Tests?