Prompt engineering in LLMs for automated unit test generation: A large-scale study
This program is tentative and subject to change.
Unit testing is essential for software reliability, yet manual test creation is time-consuming and often neglected. Although search-based software testing improves efficiency, it produces tests with poor readability and maintainability. Although LLMs show promise for test generation, existing research lacks comprehensive evaluation across execution-driven assessment, reasoning-based prompting, and real-world testing scenarios. This study presents the first large-scale empirical evaluation of LLM-generated unit tests at the full class level, systematically analyzing four state-of-the-art models (GPT-3.5, GPT-4, Mistral 7B, and Mixtral 8x7B) against EvoSuite across 216,300 generated test cases targeting Defects4J, SF110, and CMD (a dataset mitigating LLM training data leakage). We evaluate five prompting techniques–Zero-Shot Learning (ZSL), Few-Shot Learning (FSL), Chain-of-Thought (CoT), Tree-of-Thought (ToT), and Guided Tree-of-Thought (GToT)–assessing syntactic correctness, compilability, hallucination-driven failures, readability, code coverage metrics, and test smells. Reasoning-based prompting particularly GToT significantly enhances test reliability, compilability, and structural adherence in general-purpose LLMs. However, hallucination-driven failures remain a persistent challenge, manifesting as non-existent symbol references, incorrect API calls, and fabricated dependencies, resulting in high compilation failure rates (up to 86%). Moreover, test smell analysis reveals that while LLM-generated tests are generally more readable than those produced by traditional tools, they still suffer from recurring design issues such as Magic Number Tests and Assertion Roulette, which hinder maintainability. Overall, our findings indicate that LLMs can serve as effective assistive tools for generating readable and maintainable test suites, but hybrid approaches that combine LLM-based generation with automated validation and search-based refinement are required to achieve reliable and production-ready test generation.
This program is tentative and subject to change.
Thu 8 OctDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
14:00 - 15:30 | AI-Assisted Testing and Quality AssuranceESEM - Technical Track / ESEM - Software Engineering in Practice Track / ESEM - Journal First Track at Jupiter | ||
14:00 15mTalk | Explanation-Guided Metamorphic Testing of Specialized Language Models: An Empirical Study ESEM - Technical Track Xingcheng Chen Technical University of Munich & fortiss GmbH, Mehmet Besenk Technical University of Munich, Andrea Stocco Technical University of Munich, fortiss Pre-print | ||
14:15 15mTalk | FDRRestTest: Feedback-Driven Logical Testing for REST APIs ESEM - Technical Track Yutong Huo China University of Geosciences (Wuhan), Dongcheng Li California State Polytechnic University | ||
14:30 15mTalk | ARIA - An Agentic Framework for Autonomous Testing of Infotainment Systems ESEM - Software Engineering in Practice Track António Henrique Martins Azevedo Critical TechWorks, Portugal and Faculty of Engineering, University of Porto, Portugal, Bruno Lima LIACC, Faculty of Engineering, University of Porto, João Pascoal Faria Faculty of Engineering, University of Porto and INESC TEC Pre-print | ||
14:45 15mTalk | Local LLMs for End-to-End Testing in Practice: Lessons from a Smart City Web Application ESEM - Software Engineering in Practice Track Fabio Moretti ENEA, Simone Ronzoni University of Bergamo (Italy), Patrizia Scandurra University of Bergamo, Italy, Vincenzo Scotti Karlsruhe Institute of Technology (KIT) | ||
15:00 15mTalk | Don't bother to use a second LLM and write tests yourself! A Study on Elixir ESEM - Technical Track Noah Leu Lestio, Julian Oertel University of Rostock, Regina Hebig Universität Rostock, Rostock, Germany | ||
15:15 15mTalk | Prompt engineering in LLMs for automated unit test generation: A large-scale study ESEM - Journal First Track Wendkuuni C OUEDRAOGO University of Luxembourg, Abdoul Kader Kaboré University of Luxembourg, Yinghua Li Nanjing University of Science and Technology, Haoye Tian Aalto University, Anil Koyuncu Bilkent University, Jacques Klein University of Luxembourg, David Lo Singapore Management University, Tegawendé F. Bissyandé University of Luxembourg | ||