Automated Test Suite Enhancement Using Large Language Models with Few-shot Prompting
Alex Chudic (1), G\"ul \c{C}al{\i}kl{\i} (2) ((1) US Booking Services Ltd. (freetobook), (2) University of Glasgow)

TL;DR
This paper explores how few-shot prompting with large language models, using different sources of examples, can enhance the quality of automatically generated unit tests in software development, improving correctness, coverage, and readability.
Contribution
It empirically evaluates the impact of different few-shot prompting strategies on LLM-generated unit tests, highlighting the effectiveness of human examples and similarity-based retrieval methods.
Findings
Human-written examples yield the best coverage and correctness.
Similarity-based retrieval improves prompt effectiveness.
Few-shot prompting with LLMs can produce high-quality unit tests.
Abstract
Unit testing is essential for verifying the functional correctness of code modules (e.g., classes, methods), but manually writing unit tests is often labor-intensive and time-consuming. Unit tests generated by tools that employ traditional approaches, such as search-based software testing (SBST), lack readability, naturalness, and practical usability. LLMs have recently provided promising results and become integral to developers' daily practices. Consequently, software repositories now include a mix of human-written tests, LLM-generated tests, and those from tools employing traditional approaches such as SBST. While LLMs' zero-shot capabilities have been widely studied, their few-shot learning potential for unit test generation remains underexplored. Few-shot prompting enables LLMs to learn from examples in the prompt, and automatically retrieving such examples could enhance test…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Testing and Debugging Techniques · Software Engineering Research · Machine Learning and Algorithms
