Abstract
Unit testing is essential for software quality assurance, yet writing and maintaining tests remains time-consuming and error-prone. To address this challenge, researchers have proposed techniques for automating unit test generation, including heuristic-based methods and more recent approaches that leverage large language models (LLMs). However, these approaches are inherently path-insensitive because they rely on fixed heuristics or limited contextual information and fail to reason about deep control-flow structures, which leads to inadequate coverage, especially for deep execution paths. JUnitGenie extracts code knowledge from Java projects, distills it into structured prompts, and guides LLMs to generate high-coverage tests. We evaluate JUnitGenie on 2,258 complex focal methods from ten real-world Java projects. Results show that JUnitGenie improves branch coverage by an average of 29.60% and line coverage by 31.00% over both heuristic and LLM-based baselines, and generalizes effectively across both closed- and open-source foundation models. JUnitGenie is available at https://github.com/Dianshu-Liao/JUnitGenie-ICSE-Demo, and the demo video is available at https://www.youtube.com/watch?v=-jWJaf661mw.

This publication has 12 references indexed in Scilit: