用提示词优化让大模型自动生成边界值测试用例。
Evaluating Large Language Models for the Generation of Unit Tests with Equivalence Partitions and Boundary Values
- 设计包含需求与代码的优化提示词,覆盖等价类和边界值。
- 大模型生成用例效果依赖提示设计与需求清晰度。
- 需人工质检,适合开发者辅助测试生成场景。
单元测试的设计与实现对程序员而言复杂且常被忽视。本研究评估大语言模型(LLMs)在自动生成测试用例方面的潜力,并与人工测试进行对比。通过整合代码与需求信息,设计了优化的提示词,涵盖等价类划分和边界值等关键测试场景。借助定量指标与人工定性分析,比较了大模型与受训程序员的表现。结果表明,大模型的有效性取决于精心设计的提示、稳健的实现及精确的需求描述。尽管灵活且前景广阔,大模型仍需人工监督。该研究强调人工定性分析在单元测试评估中作为自动化补充的重要性。
原文摘要 · Abstract (English)
The design and implementation of unit tests is a complex task many programmers neglect. This research evaluates the potential of Large Language Models (LLMs) in automatically generating test cases, comparing them with manual tests. An optimized prompt was developed, that integrates code and requirements, covering critical cases such as equivalence partitions and boundary values. The strengths and weaknesses of LLMs versus trained programmers were compared through quantitative metrics and manual qualitative analysis. The results show that the effectiveness of LLMs depends on well-designed prompts, robust implementation, and precise requirements. Although flexible and promising, LLMs still require human supervision. This work highlights the importance of manual qualitative analysis as an essential complement to automation in unit test evaluation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。