Static Program Analysis Guided LLM Based Unit Test Generation

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

Institutions

Publication Details

Published
2024-12-18
DOI
https://doi.org/10.1145/3703323.3703742
Citations
2
Primary Topic
Software Testing and Debugging Techniques
Type
article
Field-Weighted Citation Impact
0.97
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Static Program Analysis Guided LLM Based Unit Test Generation

Joy Bose, Ricardo Britto, Giriprasad Sridhara, Sujoy Roy Chowdhury et al.
2 citations
Software Testing and Debugging Techniques
0.97
article

Static Program Analysis Guided LLM Based Unit Test Generation

Joy Bose, Ricardo Britto, Giriprasad Sridhara, Sujoy Roy Chowdhury, Sourav Mazumdar, Anusha Raghavan, H. C. Singh, Srinivasan Bajji Sugumaran
article en
2 citations

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.

Ericsson (Sweden) (SE)
Openalex Percentile: Top 19%
Software Testing and Debugging Techniques
0.97
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Static Program Analysis Guided LLM Based Unit Test Generation — Joy Bose, Ricardo Britto, et al. · (2024) | TGRS Research Map | TGRS