Code Agents are State of the Art Software Testers

Niels Mündler, Mark Niklas Müller, Jingxuan He, Martin T. Vechev · OpenReview

Abstract

Rigorous software testing is crucial for developing and maintaining high-quality code, making automated test generation a promising avenue for both improving software quality and boosting the effectiveness of code generation methods. However, while code generation with Large Language Models (LLMs) is an extraordinarily active research area, test generation remains relatively unexplored. We address this gap and investigate the capability of LLM-based Code Agents for formalizing user issues into test cases. To this end, we propose a novel benchmark based on popular GitHub repositories, containing real-world issues, ground-truth patches, and golden tests. We find that LLMs generally perform surprisingly well at generating relevant test cases with Code Agents designed for code repair exceeding the performance of systems designed specifically for test generation. Further, as test generation is a similar but more structured task than code generation, it allows for a more fine-grained analysis using fail-to-pass rate and coverage metrics, providing a dual metric for analyzing systems designed for code repair. Finally, we find that generated tests are an effective filter for proposed code fixes, doubling the precision of SWE-Agent.

Introduction

In professional software engineering, the "reproduction test" is the gold standard for bug resolution. When a bug is reported, a developer's first task is to write a test that fails on the current codebase but passes once the fix is applied. Despite its importance, this process is often tedious and has seen less AI-driven innovation compared to direct code generation or bug fixing.

Recent research from ETH Zurich and LogicStar.ai introduces SWT-Bench, a benchmark designed to evaluate whether AI "Code Agents" can bridge this gap. The study reveals a significant shift in the landscape: general-purpose coding agents are now outperforming specialized test-generation tools in creating executable reproduction tests from natural language bug reports.

The SWT-Bench Benchmark

To evaluate these capabilities at scale, the researchers curated SWT-Bench, a dataset comprising 1,983 task instances from 12 popular open-source Python repositories, including django, scikit-learn, and flask. Each instance pairs a real-world GitHub issue with its original codebase and a ground-truth "golden" fix. A smaller subset, SWT-Bench-Lite (276 issues), was also created for more efficient evaluation.

Methodology

The study explored three primary approaches to automated testing:

  1. Code Agents: Existing agents like SWE-Agent, Aider, and AutoCodeRover were adapted for testing. Rather than fixing bugs, they were tasked with creating unit tests to reproduce them. These agents operate in a loop, allowing them to search the codebase, execute tests, and iterate based on terminal output.
  2. Fault-Tolerant Diff Format: To overcome the fragility of standard unified diffs, the authors introduced a robust format that allows LLMs to modify code without requiring precise line numbers, significantly improving zero-shot performance. The custom format reportedly tripled the success rate of zero-shot LLMs compared to standard git diffs.
  3. Test-Driven Validation: A workflow where agents generate a reproduction test before proposing a fix, using the test as a filter to validate the subsequent code repair.
The SWT-Bench task: converting natural language issues into executable fail-to-pass tests.

Key Results

The evaluation yielded several surprising insights into the state of AI-driven software testing:

  • Agents Outperform Specialized Tools: General-purpose agents like SWE-Agent+ achieved a success rate of 18.5% on SWT-Bench-Lite, surpassing LIBRO (14.1%), the previous state-of-the-art specialized testing tool. This suggests that the ability to reason through a codebase and interact with a terminal is more critical than specialized testing heuristics.
  • Precision Doubling via Filtering: Using self-generated tests to filter proposed code fixes proved highly effective. For SWE-Agent, this "test-driven" approach doubled precision from approximately 20% to 47.8%, as the agent could verify its own fixes against its reproduction tests.
  • Coverage and Success Metrics: The structured nature of test generation allowed for detailed analysis using coverage metrics. As shown in the performance comparison, agents consistently provided higher coverage improvements ($\Delta \mathcal{C}$) compared to zero-shot or specialized baselines.
Performance comparison of various test generation methods across coverage metrics.

Conclusion and Future Work

While the results are promising, the study notes limitations, including a current focus on Python and the inherent risk of data contamination from public GitHub issues. Future work will involve expanding the benchmark to other languages and implementing "rolling" benchmarks with the latest issues to mitigate training data overlap.

Ultimately, SWT-Bench demonstrates that code agents are not just for writing code—they are becoming the new state-of-the-art in software testing, offering a path toward more reliable and automated software maintenance.

Summary updated

BibTeX
@inproceedings{mundler2024code,
  author = {Niels Mündler and Mark Niklas Müller and Jingxuan He and Martin T. Vechev},
  title = {{Code Agents are State of the Art Software Testers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=9Y8zUO11EQ},
}
Figure