Static Program Analysis Guided LLM Based Unit Test Generation

Sujoy Roychowdhury, Giriprasad Sridhara, A K Raghavan, Joy Bose, Sourav Mazumdar +3 more
3/7/2025
cs.SEcs.AI

No confident code implementation found for this 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.

Show full abstract

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 \emph{concise} and \emph{precise} context information obtained by program analysis %of the focal method 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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{roychowdhury2025static,
  title  = {Static Program Analysis Guided LLM Based Unit Test Generation},
  author = {Sujoy Roychowdhury and Giriprasad Sridhara and A K Raghavan and Joy Bose and Sourav Mazumdar and Hamender Singh and Srinivasan Bajji Sugumaran and Ricardo Britto},
  year   = {2025},
  eprint = {2503.05394},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2503.05394v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2503.05394.svg)](https://codeofpaper.com/paper/2503.05394)

Discussion