paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Domain Adaptation for Code Model-Based Unit Test Case Generation

面向基于代码模型的单元测试用例生成的领域自适应
ISSTA Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis2024匹配度 2/10 · 论文聚焦基于代码模型(CodeT5)的单元测试生成与项目级领域自适应,属于测试生成/软件工程方向;它不涉及静态分析、形式化验证、Agentic 程序、浮点程序分析或贝叶斯程序分析,与用户核心研究画像交叉有限。虽然使用代码模型并对比 GPT-4,但研究目标不是 LLM/Agent 作为工具改进程序分析,而是小模型微调生成测试,因此匹配度较低。引用 27 inbox
Jiho Shin, Sepehr Hashtroudi, Hadi Hemmati, Song Wang
crossref: 2026-09-12

AI 速览

一句话:用 CodeT5 微调并做项目级领域自适应,提升单元测试生成覆盖率与变异得分。

论文研究如何用深度学习自动生成单元测试。作者以在源码上预训练的 CodeT5 为基础,先在 Methods2test 数据集上微调测试生成任务,再针对每个目标项目进行项目级领域自适应,以学习项目特定知识。在 Defects4j 的五个项目上,与未做领域自适应的 CodeT5、A3Test 和 GPT-4 比较,生成测试的行覆盖率分别提升 18.62%、19.88%、18.02%,变异得分提升 16.45%、16.01%、12.99%;解析率、编译率、BLEU 和 CodeBLEU 也整体改善。该方法还可与 EvoSuite 等搜索式测试生成工具互补,平均提升行覆盖率 34.42%、变异得分 6.8%。

问题
如何利用预训练代码模型自动生成高质量单元测试,并缓解模型在不同项目间知识迁移不足的问题。
方法
在 Methods2test 上微调 CodeT5 做测试生成,再对每个目标项目执行项目级领域自适应,使模型学习项目特定知识。
评估
在 Defects4j 五个项目上与无 DA 的 CodeT5、A3Test、GPT-4 比较行覆盖率、变异得分、解析率、编译率、BLEU/CodeBLEU,并与 EvoSuite 组合评估互补性。
原文摘要(Abstract)

Recently, deep learning-based test case generation approaches have been proposed to automate the generation of unit test cases. In this study, we leverage Transformer-based code models to generate unit tests with the help of Domain Adaptation (DA) at a project level. Specifically, we use CodeT5, a relatively small language model trained on source code data, and fine-tune it on the test generation task. Then, we apply domain adaptation to each target project data to learn project-specific knowledge (project-level DA). We use the Methods2test dataset to fine-tune CodeT5 for the test generation task and the Defects4j dataset for project-level domain adaptation and evaluation. We compare our approach with (a) CodeT5 fine-tuned on the test generation without DA, (b) the A3Test tool, and (c) GPT-4 on five projects from the Defects4j dataset. The results show that tests generated using DA can increase the line coverage by 18.62%, 19.88%, and 18.02% and mutation score by 16.45%, 16.01%, and 12.99% compared to the above (a), (b), and (c) baselines, respectively. The overall results show consistent improvements in metrics such as parse rate, compile rate, BLEU, and CodeBLEU. In addition, we show that our approach can be seen as a complementary solution alongside existing search-based test generation tools such as EvoSuite, to increase the overall coverage and mutation scores with an average of 34.42% and 6.8%, for line coverage and mutation score, respectively.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8593,
  title = {Domain Adaptation for Code Model-Based Unit Test Case Generation},
  author = {Jiho Shin and Sepehr Hashtroudi and Hadi Hemmati and Song Wang},
  booktitle = {ISSTA},
  year = {2024},
  doi = {10.1145/3650212.3680354}
}