Static Analysis and LLM for Comprehensive Java Unit Test Generation

Wei Wei · 2025

Software testing is crucial in ensuring the reliability and correctness of software applications. However, generating comprehensive test cases manually can be time-consuming and error-prone. This paper introduces SAGEN, a tool designed to automate Java unit test generation by leveraging static analysis of Syntax Trees (AST) and large language models (LLMs). SAGEN identifies literal values and their ranges, generating test cases that improve coverage and quality. In our experiments, SAGEN outperforms traditional test case generation tools such as EvoSuite and Randoop. It demonstrates a $10 \%$ improvement in code coverage and a $13 \%$ enhancement in test case quality. Furthermore, SAGEN achieves a compile pass rate of $89.7 \%$, proving its effectiveness in producing both high-quality and reliable test cases.

Read the paper · More papers on PaperTik