paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Learning Deep Semantics for Test Completion

面向测试补全的深度语义学习
ICSE 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE)2023匹配度 3/10 · 该论文属于深度学习辅助测试补全,利用代码执行语义,但与用户核心关注的静态分析、LLM/Agent 改进程序分析、浮点程序分析或贝叶斯程序分析均无直接关联。引用 110 inbox
Pengyu Nie, Rahul Banerjee, Junyi Jessy Li, Raymond J. Mooney, Milos Gligoric
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出测试补全任务,并设计利用代码执行语义的深度学习模型 TECO,自动补全测试方法中的下一条语句。

测试编写耗时但关键。论文提出用深度学习辅助编写测试,并形式化新任务“测试补全”:根据测试方法已有语句和被测代码,自动补全下一条语句。作者提出 TECO 模型,核心观点是预测下一条语句需要推理代码执行,仅靠语法级数据难以完成;TECO 抽取并使用六类代码语义数据,包括先前语句的执行结果和测试方法的执行上下文。评估使用从 1,270 个开源 Java 项目收集的 130,934 个测试方法。结果显示,TECO 精确匹配准确率为 18%,比仅用语法数据的最佳基线高 29%;生成语句在 29% 情况下可运行,而最佳基线为 18%;在测试 oracle 生成上亦显著优于先前工作。

问题
如何利用深度学习辅助开发者编写测试,尤其是根据测试方法和被测代码的上下文自动补全下一条测试语句。
方法
提出 TECO,使用六类代码语义数据(含执行结果与执行上下文)进行测试补全,突破仅依赖语法级数据的代码补全模型。
评估
在从 1,270 个开源 Java 项目收集的 130,934 个测试方法上评估,比较精确匹配、生成语句可运行性及测试 oracle 生成效果。
原文摘要(Abstract)

Writing tests is a time-consuming yet essential task during software development. We propose to leverage recent advances in deep learning for text and code generation to assist developers in writing tests. We formalize the novel task of test completion to automatically complete the next statement in a test method based on the context of prior statements and the code under test. We develop TECo-a deep learning model using code semantics for test completion. The key insight underlying TECO is that predicting the next statement in a test method requires reasoning about code execution, which is hard to do with only syntax-level data that existing code completion models use. Teco extracts and uses six kinds of code semantics data, including the execution result of prior statements and the execution context of the test method. To provide a testbed for this new task, as well as to evaluate TECO, we collect a corpus of 130,934 test methods from 1,270 open-source Java projects. Our results show that Teco achieves an exact-match accuracy of 18, which is 29% higher than the best baseline using syntax-level data only. When measuring functional correctness of generated next statement, Teco can generate runnable code in 29% of the cases compared to 18% obtained by the best baseline. Moreover, Teco is sianificantly better than prior work on test oracle generation.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{abs-2302-10166,
  title = {Learning Deep Semantics for Test Completion},
  author = {Pengyu Nie and Rahul Banerjee and Junyi Jessy Li and Raymond J. Mooney and Milos Gligoric},
  booktitle = {ICSE},
  year = {2023},
  doi = {10.1109/icse48619.2023.00178}
}