YATE: The Role of Test Repair in LLM-Based Unit Test Generation

Michael Konstantinou, Renzo Degiovanni, Jie M. Zhang, Mark Harman, Mike PapadakisarXiv 2025 · DOI

Abstract

Large Language Models (LLMs) have shown significant promise in automated unit test generation but frequently produce "near-miss" tests—code that is logically sound but fails due to minor syntactic or semantic errors. This paper introduces YATE (Yet Another Test Engineer), a framework that prioritizes the repair of these tests over their disposal. By integrating rule-based static analysis, retrieval-augmented generation for dependency resolution, and runtime oracle fixing, YATE achieves a 51% branch coverage on real-world Java projects, significantly outperforming existing state-of-the-art tools while maintaining computational efficiency.

Introduction

While LLMs are proficient at writing unit tests, they suffer from a high "hallucination" rate, often generating tests that fail due to missing imports, incorrect constructors, or flawed assertions. In traditional automated workflows, these broken tests are discarded, representing a significant loss of potential coverage. YATE addresses this "missed opportunity" by systematically repairing these near-miss tests. The core hypothesis is that these tests often contain the correct logic to exercise complex code paths and merely require targeted intervention to become executable.

Methodology

YATE employs a four-stage workflow designed to mimic the iterative debugging process of a human developer:

  1. Initial Generation with Chain-of-Thought (CoT): The LLM first plans the test cases by analyzing the target class, which encourages reasoning about edge cases before code generation.
  2. Compilation Error Fixing: Instead of simply passing error messages back to the LLM, YATE uses static analysis to identify missing dependencies. It then fetches relevant class signatures from the project and provides them as context, utilizing a form of Retrieval-Augmented Generation (RAG).
  3. Oracle (Assertion) Fixing: For tests that compile but fail, YATE observes runtime values and uses rule-based logic to synchronize expected values with actual program output or correct exception-handling logic.
  4. Coverage-Based Augmentation: Finally, YATE identifies remaining uncovered branches and initiates a targeted generation round to fill those specific gaps.
The YATE four-stage workflow: Generation with CoT, Compilation Fixing, Oracle Fixing, and Coverage Augmentation.

Experimental Evaluation

The framework was evaluated using six real-world open-source Java projects, including both "seen" data and "unseen" data (projects created after October 2023) to account for potential LLM data leakage. YATE was compared against four state-of-the-art tools: HITS, SYMPROMPT, TESTSPARK, and COVERUP.

Key Results

  • Superior Coverage: YATE achieved an average of 51% branch coverage, outperforming HITS (30%), SYMPROMPT (27%), and COVERUP (25%).
  • Mutation Analysis: Compared to standard LLM prompting, YATE improved line coverage by 32.06% and increased the mutation score (a proxy for bug-finding effectiveness) by 21.77%.
  • Efficiency: YATE (class-level) proved to be the most cost-efficient approach overall, balancing the number of LLM calls against the resulting coverage gains.
Performance metrics across six projects showing improvements and differences in Line Coverage, Branch Coverage, and Mutation Score for Class and Method-level generation.

Discussion and Insights

The study revealed several critical insights into LLM-based testing. First, repairing existing tests is often more valuable than generating new ones from scratch, as the broken test already targets specific logic. Second, providing context regarding compilation and dependencies is more critical for success than providing coverage feedback; if a model cannot produce executable code, coverage data is moot. Finally, while method-level generation yields higher coverage by focusing the LLM's attention, it comes at a higher computational cost compared to class-level generation.

Conclusion and Future Work

YATE demonstrates that systematic test repair can significantly bridge the gap between LLM-generated code and executable test suites. Current limitations include a dependency on Java-specific static analysis tools and the "Oracle Problem," where the tool assumes the current code behavior is correct (regression testing). Future research will focus on porting the framework to other languages and developing hybrid strategies to optimize the cost-to-coverage ratio.

Summary updated

BibTeX
@misc{konstantinou2025yate,
  author = {Michael Konstantinou and Renzo Degiovanni and Jie M. Zhang and Mark Harman and Mike Papadakis},
  title = {{YATE: The Role of Test Repair in LLM-Based Unit Test Generation}},
  year = {2025},
  eprint = {2507.18316},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.18316},
}
Figure