MAPS: Leveraging Large Language Models for Efficient Test Case Generation

Friday 28 February 2025


The quest for efficient test case generation has long been a thorn in the side of software developers. With the rise of large language models (LLMs), researchers have been exploring new ways to harness their power for automated testing. A recent paper presents MAPS, an innovative approach that leverages LLMs to generate effective prompts for test cases.


The problem with traditional test case generation is that it often relies on human-written prompts, which can be time-consuming and prone to errors. Moreover, the quality of these prompts can vary greatly depending on the individual writing them. MAPS addresses this issue by using an evolutionary algorithm to optimize prompt design. This approach allows for the creation of diverse and effective prompts tailored to specific LLMs.


The authors’ solution consists of three modules: Diversity-Guided Prompt Generation, Failure-Driven Rule Induction, and Domain Contextual Knowledge Extraction. The first module creates a pool of varied prompts by exploring different modification paths during optimization. This ensures that the generated prompts are diverse and less likely to converge on local optima.


The second module identifies promising optimization directions by reflecting common failures in generated test cases. This is achieved through a soft integration of rule transformations into prompts based on the failure data. By incorporating this feedback, MAPS can adapt its prompt generation strategy to better address specific testing challenges.


Domain Contextual Knowledge Extraction is the third component, which enriches prompts with related domain knowledge by incorporating both in-file and cross-file context information. This module helps LLMs understand the relationships between different code elements, leading to more accurate test case generation.


To evaluate MAPS, the authors conducted experiments across three popular LLMs, comparing their approach to four state-of-the-art prompt optimization methods. The results show that MAPS outperforms these methods by a significant margin, achieving higher line and branch coverage rates on average.


The implications of this research are far-reaching. By leveraging LLMs for test case generation, developers can significantly reduce the time and effort required for testing software applications. Moreover, the ability to generate effective prompts automatically opens up new possibilities for code intelligence and automated programming tasks.


As software development continues to evolve, it’s clear that AI-powered tools like MAPS will play an increasingly important role in streamlining the testing process. With its innovative approach to prompt optimization, this research takes a major step towards making automated testing more efficient, effective, and accessible.


Cite this article: “MAPS: Leveraging Large Language Models for Efficient Test Case Generation”, The Science Archive, 2025.


Test Case Generation, Large Language Models, Automated Testing, Prompt Optimization, Evolutionary Algorithm, Diversity-Guided Prompt Generation, Failure-Driven Rule Induction, Domain Contextual Knowledge Extraction, Code Intelligence, Software Development.


Reference: Shuzheng Gao, Chaozheng Wang, Cuiyun Gao, Xiaoqian Jiao, Chun Yong Chong, Shan Gao, Michael Lyu, “The Prompt Alchemist: Automated LLM-Tailored Prompt Optimization for Test Case Generation” (2025).


Leave a Reply