Work

Static Program Analysis Guided LLM Based Unit Test Generation

Year: 2024
Type: conference-paper
Abstract: We describe a novel approach to automating unit test generation for Java methods using large language models (LLMs). Existing LLM-based approaches rely on sample usage(s) of the method to test (focal method) and/or provide the entire class of the focal method as input prompt and context. The former approach is often not viable due to the lack of sample usages, especially for newly written focal methods. The latter approach does not scale well enough; the bigger the complexity of the focal method and larger associated class, the harder it is to produce adequate test code (due to factors such as exceeding the prompt and context lengths of the underlying LLM). We show that augmenting prompts with concise and precise context information obtained by program analysis increases the effectiveness of generating unit test code through LLMs. We validate our approach on a large commercial Java project and a popular open-source Java project.
Authors: Sujoy Roy Chowdhury, Giriprasad Sridhara, A K Raghavan, Joy Bose, Sourav Mazumdar, Hamender Singh, Srinivasan Bajji Sugumaran, Ricardo Britto
Institution: Ericsson (Sweden)
Language: English
Subfield: Software
Open Access status: gold
OpenAlex ID: W4411624689
FWCI: 0.874
Cites: 5
Cited by: 3
Related to: 10