AgentTester: An LLM-Based Tool for Unit Test Generation with Automatically Generated Prompts
摘要
Unit tests are critical for software reliability, yet manually writing them is laborious and time-consuming. While traditional tools like EvoSuite achieve high coverage, their low readability limits adoption. Recent LLM-based methods (e.g., AthenaTest, ChatTester) improve test readability but suffer from suboptimal prompt design and rigid template-based instructions that lack adaptability to different focal methods. To address these limitations, we propose AgentTester—an LLM-based method with three core components: 1) AutoPrompting that extracts the essential information of focal method and infers method intent, 2) Prompt Distillation to refine tailored test instructions via multi-temperature sampling before generating the unit tests, and 3) Validation-Repair for iterative error correction of buggy test cases. Experimental evaluations show AgentTester surpasses EvoSuite in line coverage and outperforms both AthenaTest and ChatTester in compilation rate, test correctness, and overall coverage. These results demonstrate AgentTester’s effectiveness in generating reliable, adaptable and universality unit tests.