Test Intention Guided LLM-Based Unit Test Generation
Zifan Nan, Zhaoqiang Guo, Kui Liu, Xin Xia
Abstract
The emergence of Large Language Models (LLMs) has accelerated the progress of intelligent software engineering technologies, which brings promising possibilities for unit test generation. However, existing approaches for unit tests directly generated from Large Language Models (LLMs) often prove impractical due to their low coverage and insufficient mocking capabilities. This paper proposes IntUT, a novel approach that utilizes explicit test intentions (e.g., test inputs, mock behaviors, and expected results) to effectively guide the LLM to generate high-quality test cases. Our experimental results on three industry Java projects and live study demonstrate that prompting LLM with test intention can generate high-quality test cases for developers. Specifically, it achieves the improvements on branch coverage by 94 % and line coverage by 49 %. Finally, we obtain developers' feedback on using IntUT to generate cases for three new Java projects, achieving over 80 % line coverage and 30 % efficiency improvement on writing unit test cases.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Your agent calls
Lunesearch_papers
Free to start. No credit card required.
Terminal
Install the CLIlune papers get 1bbe199a-5e49-4be9-afe2-7bac03ac49a4Cited by top-tier papers5
- Generating Project-Specific Test Cases with Requirement Validation IntentionBinhang Qi, Yun Lin, Xinyi Weng, Yuhuan Huang et al.ISSTA 2026 · 3 citations
- Navigating the Labyrinth: Path-Sensitive Unit Test Generation with Large Language ModelsDianshu Liao, Xin Yin, Shidong Pan, Chao Ni et al.ASE 2025 · 2 citations
- Generalizing Test Cases for Comprehensive Test Scenario CoverageBinhang Qi, Yun Lin, Xinyi Weng, Chenyan Liu et al.FSE 2026 · 1 citation
- Change And Cover: Last-Mile, Pull Request-Based Regression Test AugmentationZitong Zhou, Matteo Paltenghi, Miryung Kim, Michael PradelICSE 2026
- AdaDec: A Uncertainty-Guided Lookahead Decoding Framework for LLM-Based Code GenerationKaifeng He, Mingwei Liu, Chong Wang, Zike Li et al.FSE 2026
Related papers
- On the Evaluation of Large Language Models in Unit Test GenerationLin Yang, Chen Yang, Shutao Gao, Weijing Wang et al.ASE 2024 · 42 citations
- STRUT: Structured Seed Case Guided Unit Test Generation for C Programs using LLMsJinwei Liu, Chao Li, Rui Chen, Shaofeng Li et al.ISSTA 2025 · 6 citations
- LLMs for Automated Unit Test Generation and Assessment in Java: The AgoneTest FrameworkAndrea Lops, Fedelucio Narducci, Azzurra Ragone, Michelantonio Trizio et al.ASE 2025 · 1 citation
- A Large-Scale Empirical Study on Fine-Tuning Large Language Models for Unit TestingYe Shang, Quanjun Zhang, Chunrong Fang, Siqi Gu et al.ISSTA 2025 · 7 citations
- Evaluating and Improving ChatGPT for Unit Test GenerationZhiqiang Yuan, Mingwei Liu, Shiji Ding, Kaixin Wang et al.FSE 2024 · 89 citations
