ConUT: Condition-Aware Test Generation for Complex Java Code
Ruiguo Yu, Ruiqi Dong, Xi Xiao, Xiaogang Zhu, Shaohua Wang, Sheng Wen, Qing Li
Abstract
Automatically generating high-coverage unit tests for complex Java methods remains a formidable challenge, particularly when execution paths are guarded by intricate control-flow nesting and cross-class state dependencies. Existing LLM-based approaches predominantly follow a goal-driven paradigm , relying on unguided code synthesis within a vast search space to satisfy coverage objectives. Lacking explicit guidance on how to construct the precise object states required for complex predicates, these methods suffer from a construction-reachability gap, ultimately resulting in insufficient coverage for complex methods. This paper introduces ConUT, a condition-aware unit test generation framework centered on the paradigm of Configuration-Driven Guidance, which is a strategy that bridges the gap between abstract branch targets and concrete code realization by providing the LLM with structured instantiation recipes. Our core insight is that the implicit causal chain leading to a target branch can be explicitly manifested via static analysis and distilled into structured guidance. ConUT utilizes Backward Dependency Tracing (BDT) to identify the fields and method calls that influence predicates, and distills these findings into structured Configuration Templates ( C cfg ). These templates serve as a “semantic roadmap,” pruning the LLM’s search space and transitioning it from a stochastic generator into a guided logic realizer. We evaluate ConUT on eight real-world Java projects characterized by high-complexity “logic hotspots.” Experimental results demonstrate that ConUT outperforms state-of-the-art baselines, achieving an average branch coverage of 72.84% and line coverage of 83.87%. Notably, ConUT exceeds the best baseline in average branch coverage by 11.94 percentage points while utilizing 67% fewer 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 625cf733-71bd-446c-96bb-267c40f8f9bdRelated papers
- 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
- Context Matters: Improving the Practical Reliability of LLM-Based Unit Test Generation (Experience Paper)Junjie Chen, Ziqi Wang, Lin Yang, Chen Yang et al.ISSTA 2026
- TestTailor: Generating High-Coverage Tests via Path-Proximal Tests with LLMsXiaoxuan Zhou, Yiling Lou, Jinhao Dong, Dan HaoFSE 2026
- LLM Test Generation via Iterative Hybrid Program AnalysisSijia Gu, Noor Nashid, Ali MesbahICSE 2026 · 6 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
