Test suites tend to grow when software evolves, making it often infeasible to execute all test cases with the allocated testing budgets, especially for large software systems. Test suite minimization (TSM) is employed to improve the efficiency of software testing by removing redundant test cases, thus reducing testing time and resources, while maintaining the fault detection capability of the test suite. Most existing TSM approaches rely on code coverage (white-box) or model-based features, which are not always available to test engineers. Recent TSM approaches that rely only on test code (black-box) have been proposed, such as ATM and FAST-R. To address the scalability, we propose LTM (Language model-based Test suite Minimization), a novel, scalable, and black-box similarity-based TSM approach based on large language models (LLMs), which is the first application of LLMs in the context of TSM. To support similarity measurement for test code embeddings, we investigate five pre-trained language models: CodeBERT, GraphCodeBERT, UniXcoder, StarEncoder, and CodeLlama, on which we compute two similarity measures: Cosine Similarity and Euclidean Distance. Our goal is to find similarity measures that are not only computationally more efficient but can also better guide a Genetic Algorithm (GA) to search for optimal minimized test suites, thus reducing the overall search time. Experimental results show that the best configuration of LTM (UniXcoder/Cosine) outperforms ATM in three aspects: (a) achieving a slightly greater saving rate of testing time (41.72% versus 40.29%, on average); (b) attaining a significantly higher fault detection rate (0.84 versus 0.81, on average); and, most importantly, (c) minimizing test suites nearly five times faster on average, with higher gains for larger test suites and systems, thus achieving much higher scalability.
翻译:测试套件在软件演化过程中往往会不断增长,导致在有限的测试预算内难以执行所有测试用例,尤其对于大型软件系统。测试用例集约简(TSM)通过移除冗余测试用例来提高软件测试效率,在保持测试套件故障检测能力的同时减少测试时间和资源消耗。现有TSM方法大多依赖代码覆盖(白盒)或基于模型的特征,而这些特征并非总能被测试工程师获取。近期提出的ATM和FAST-R等方法仅依赖测试代码(黑盒)实现TSM。为解决可扩展性问题,本文提出LTM(基于语言模型的测试用例集约简)——一种基于大语言模型(LLMs)的新型可扩展黑盒相似性TSM方法,这是LLMs在TSM领域的首次应用。为支持测试代码嵌入的相似性度量,我们研究了五种预训练语言模型:CodeBERT、GraphCodeBERT、UniXcoder、StarEncoder和CodeLlama,并基于这些模型计算两种相似性度量:余弦相似度和欧氏距离。我们的目标是找到不仅计算效率更高、还能更好指导遗传算法(GA)搜索最优精简测试套件的相似性度量,从而减少整体搜索时间。实验结果表明,LTM的最佳配置(UniXcoder/余弦)在三个方面优于ATM:(a)实现略高的测试时间节省率(平均41.72%对比40.29%);(b)获得显著更高的故障检测率(平均0.84对比0.81);最重要的是(c)平均精简测试套件速度提升近五倍,且对更大测试套件和系统的性能增益更高,从而实现更强的可扩展性。