arXiv:2502.14212cs.SEcs.IR2025-02

清理测试数据噪声可显著提升代码自动生成质量

Less is More: On the Importance of Data Quality for Unit Test Generation

  • 提出CleanTest框架,用三重过滤器自动识别并清除数据噪声
  • 发现Methods2Test和Atlas数据集中分别有43.52%和29.65%含噪声
  • 实验证明去噪后四大LLM生成测试用例能力明显增强

单元测试对软件开发与维护至关重要,但手动编写耗时费力。近年来,研究者尝试用深度学习或大语言模型(LLMs)自动化生成测试用例,通常依赖大规模数据集训练。尽管数据质量日益受关注,相关研究仍有限。为此,我们系统分析噪声对基于学习的测试生成模型的影响。首先采用开放卡排序法对最流行、最大的测试生成数据集Methods2Test进行分析,识别出八类噪声类型;随后对17位领域专家进行深度访谈,验证并评估噪声分类的合理性与正确性。据此提出CleanTest——一种自动化噪声清洗框架,包含规则式语法过滤、规则式相关性过滤及模型驱动的覆盖率过滤。在Methods2Test和Atlas两个常用数据集上应用CleanTest,结果显示其分别存在43.52%和29.65%的噪声,表明噪声普遍。进一步使用CodeBERT、AthenaTest、StarCoder和CodeLlama7B四款LLM进行对比实验,结果表明去除噪声能有效提升模型生成测试用例的能力。

原文摘要 · Abstract (English)

Unit testing is crucial for software development and maintenance. Effective unit testing ensures and improves software quality, but writing unit tests is time-consuming and labor-intensive. Recent studies have proposed deep learning (DL) techniques or large language models (LLMs) to automate unit test generation. These models are usually trained or fine-tuned on large-scale datasets. Despite growing awareness of the importance of data quality, there has been limited research on the quality of datasets used for test generation. To bridge this gap, we systematically examine the impact of noise on the performance of learning-based test generation models. We first apply the open card sorting method to analyze the most popular and largest test generation dataset, Methods2Test, to categorize eight distinct types of noise. Further, we conduct detailed interviews with 17 domain experts to validate and assess the importance, reasonableness, and correctness of the noise taxonomy. Then, we propose CleanTest, an automated noise-cleaning framework designed to improve the quality of test generation datasets. CleanTest comprises three filters: a rule-based syntax filter, a rule-based relevance filter, and a model-based coverage filter. To evaluate its effectiveness, we apply CleanTest on two widely-used test generation datasets, i.e., Methods2Test and Atlas. Our findings indicate that 43.52% and 29.65% of datasets contain noise, highlighting its prevalence. Finally, we conduct comparative experiments using four LLMs (i.e., CodeBERT, AthenaTest, StarCoder, and CodeLlama7B) to assess the impact of noise on test generation performance. The results show that filtering noise positively influences the test generation ability of the models.

测试生成数据清洗LLM代码质量

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。