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 suites. This paper empirically investigates how few-shot prompting with different test artifact sources, comprising human, SBST, or LLM, affects the quality of LLM-generated unit tests as program comprehension artifacts and their contribution to improving existing test suites by evaluating not only correctness and coverage but also readability, cognitive complexity, and maintainability in hybrid human-AI codebases. We conducted experiments on HumanEval and ClassEval datasets using GPT-4o, which is integrated into GitHub Copilot and widely used among developers. We also assessed retrieval-based methods for selecting relevant examples. Our results show that LLMs can generate high-quality tests via few-shot prompting, with human-written examples producing the best coverage and correctness. Additionally, selecting examples based on the combined similarity of problem description and code consistently yields the most effective few-shot prompts.
Maintenance of Automated Test Suites in Industry: An Empirical study on Visual GUI Testing
验证与确认(Verification and Validation,V&V)活动在实践中占软件系统总开发成本的20%到50%。测试自动化被提出来降低这些V&V成本,但现有的研究只提供了有限的经验数据,从工业实践中的维护成本的自动化测试和影响这些成本的因素。特别是,这些成本和因素对于基于GUI的自动化测试是未知的。目的:本文通过分析与工业实践中基于GUI的自动化测试维护相关的成本和因素,解决了这种知识的缺乏。方法:在两个公司,西门子和萨博,实证研究报告的采访,和实证工作,可视化GUI测试进行获取数据的技术的维护成本和可行性。结果:观察到13个因素,影响维修,如测试人员的知识/经验和测试用例的复杂性。此外,统计分析表明,开发新的测试脚本比维护成本更高,但频繁的维护比不频繁的大爆炸维护成本更低。此外,成本模型,在以前的工作的基础上,提出了估计的时间,以积极的投资回报率(ROI)的测试自动化相比,手动测试。结论:它的结论是,测试自动化可以降低一个项目的整体软件开发成本,同时也对软件质量有积极的影响。然而,维护成本仍然是相当可观的,公司目前花在手动测试上的时间越少,在自动化之后达到积极的、经济的ROI之前需要的时间就越多。
A System for Automated Unit Test Generation Using Large Language Models and Assessment of Generated Test Suites
Polytechnic University of Bari \& Wideverse Bari, Italy;Polytechnic University of Bari Bari, Italy;Independent Researcher;University of Bari Bari, Italy
Automated Visualization Code Synthesis via Multi-Path Reasoning and Feedback-Driven Optimization
AI Research, Enhans, Seoul, South Korea Innovation \& Technology, KAIST, Daejeon, South Korea Department of Computer Science, University of California, Berkeley, CA, United States Department of Electrical