LLM 赋能的自动化测试用例生成与优先级优化策略
  • ISSN:3135-7660(Print) 3135-7679(Online)
  • DOI:
  • 出版频率:月刊
  • 语言:中文
  • 收录数据库:Crossref

LLM 赋能的自动化测试用例生成与优先级优化策略

廖彬

上海东虹科技有限公司 陕西省西安市 201306

摘要:自动化测试用例的构造和执行顺序优化一直受到手工编写成本高、回归测试资源少的现实制约。本文提出一种基于大语言模型的测试用例自动生成与优先级排序协同框架。该框架利用多轮提示工程和检索增强生成技术,使模型能够感知目标方法的代码上下文并生成结构合理的测试用例;随后通过基于静态度量的风险预测模型对测试用例进行排序,使得高风险场景得以优先覆盖。从五个开源 Java 项目实验结果可知,该框架在分支覆盖率、变异评分上都比传统的搜索式生成、符号执行方法好,并且优先级排序策略大大提高了早期缺陷检出的比例。本文还对迭代反馈机制对生成质量的持续改善效果进行了研究,公开了实验脚本和数据,为以后的研究提供复现和比较的基础。

关键词:大语言模型;测试用例生成;测试优先级排序;检索增强生成;提示工程

参考文献

[1] Rehan S, Al-Bander B, Al-Said Ahmad A. Harnessing large language models for automated software testing: A leap towards scalable test case generation[J]. Electronics, 2025, 14(7): 1463.

[2] Guzman-Sanchez J. Risk-based test case prioritization using large language models in regression testing[D]. Greenville, NC: East Carolina University, 2025.

[3] Ardoğan B, Kilinç H H, Tarak E, et al. Understanding LLM behavior in test case prioritization: A comparative study[C]//2025 10th International Conference on Computer Science and Engineering (UBMK). IEEE, 2025: 1258-1263.

[4] Zhang Q, Shang Y, Fang C, et al. TestBench: Evaluating class-level test case generation capability of large language models[J]. Frontiers of Computer Science, 2027, 21(6): 2106202.

[5] Mahmoud Y, Azim A, Liscano R, et al. Leveraging LLM enhanced commit messages to improve machine learning based test case prioritization[C]//Proceedings of the 21st International Conference on Predictive Models and Data Analytics in Software Engineering (PROMISE 2025). ACM, 2025: 1-10.

[6] Zosimadis I, Stamelos I. LLM-enhanced test case prioritization for complex software systems[C]//Proceedings of the 28th Pan-Hellenic Conference on Progress in Computing and Informatics (PCI 2025). ACM, 2025: 45-52.

[7] Wang H, Li J, Chen Z. A comprehensive survey on large language models for test automation[J]. Journal of Systems and Software, 2026, 210: 112073.

[8] Yang S, Zhang Y, Liu T. Retrieval-augmented generation for code : A review and empirical study[J]. ACM

Transactions on Software Engineering and Methodology, 2025, 34(3): 1-36.作者简介:廖彬(1992—),男,汉族,本科,研究方向为软件测评师。