Enhancing LLM-Based Test Generation by Eliminating Covered Code

WeiZhe Xu, Mengyu Liu, Fanxin Kong
2/25/2026
cs.SEcs.AIcs.LG

No confident code implementation found for this paper.

Abstract

Automated test generation is essential for software quality assurance, with coverage rate serving as a key metric to ensure thorough testing. Recent advancements in Large Language Models (LLMs) have shown promise in improving test generation, particularly in achieving higher coverage. However, while existing LLM-based test generation solutions perform well on small, isolated code snippets, they struggle when applied to complex methods under test. To address these issues, we propose a scalable LLM-based unit test generation method. Our approach consists of two key steps. The first step is context information retrieval, which uses both LLMs and static analysis to gather relevant contextual information associated with the complex methods under test. The second step, iterative test generation with code elimination, repeatedly generates unit tests for the code slice, tracks the achieved coverage, and selectively removes code segments that have already been covered. This process simplifies the testing task and mitigates issues arising from token limits or reduced reasoning effectiveness associated with excessively long contexts. Through comprehensive evaluations on open-source projects, our approach outperforms state-of-the-art LLM-based and search-based methods, demonstrating its effectiveness in achieving high coverage on complex methods.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{xu2026enhancing,
  title  = {Enhancing LLM-Based Test Generation by Eliminating Covered Code},
  author = {WeiZhe Xu and Mengyu Liu and Fanxin Kong},
  year   = {2026},
  eprint = {2602.21997},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2602.21997v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2602.21997.svg)](https://codeofpaper.com/paper/2602.21997)

Discussion