paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Extracting Inline Tests from Unit Tests

从单元测试中提取内联测试
ISSTA Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis2023匹配度 2/10 · 论文提出从单元测试自动提取内联测试,属于软件测试生成与变异测试方向,与用户关注的静态分析、LLM/Agent 程序分析、浮点程序分析及贝叶斯程序分析没有直接交叉。其覆盖率和变异体约简虽涉及程序分析技术,但整体方向偏离核心研究画像。引用 12 inbox
Yu Liu, Pengyu Nie, Anna Guo, Milos Gligoric, Owolabi Legunsen
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:ExLi 首次实现从单元测试自动提取内联测试,并用覆盖率与变异体约简去除冗余。

内联测试允许开发者在目标语句后直接给出测试输入、期望输出和测试预言,但已有代码中目标语句数量庞大,自动生成内联测试成为推广该技术的关键。本文提出 ExLi,这是首个自动生成内联测试的技术。ExLi 在运行单元测试时记录目标语句处的所有变量值,将其作为初始内联测试的输入和预言;针对同一语句被多次执行产生的冗余测试,ExLi 采用新颖的“先覆盖率、后变异体”约简流程筛选测试。作者为 Java 实现 ExLi,并在 31 个开源程序的 718 个目标语句上评估。ExLi 将 17,273 个初始内联测试缩减为 905 个,最终生成的内联测试在目标语句上比开发者编写及自动生成的单元测试最多多杀死 25.1% 的变异体,表明其能提升原测试套件的故障检测能力。

问题
已有代码中目标语句很多,手动编写内联测试成本高,因此需要自动生成内联测试以促进其采用。
方法
ExLi 在单元测试执行时记录目标语句处的变量值,用这些值构造初始内联测试的输入与预言,并通过基于覆盖率和变异体的约简流程删除冗余测试。
评估
作者在 Java 中实现 ExLi,对 31 个开源程序的 718 个目标语句生成内联测试;初始 17,273 个测试被约简到 905 个,且最终测试比开发者编写和自动生成的单元测试最多多杀死 25.1% 的变异体。
原文摘要(Abstract)

We recently proposed inline tests for validating individual program statements; they allow developers to provide test inputs, expected outputs, and test oracles immediately after a target statement. But, existing code can have many target statements. So, automatic generation of inline tests is an important next step towards increasing their adoption. We propose ExLi, the first technique for automatically generating inline tests. ExLi extracts inline tests from unit tests; it first records all variable values at a target statement while executing unit tests. Then, ExLi uses those values as test inputs and test oracles in an initial set of generated inline tests. Target statements that are executed many times could have redundant initial inline tests. So, ExLi uses a novel coverage-then-mutants based reduction process to remove redundant inline tests. We implement ExLi for Java and use it to generate inline tests for 718 target statements in 31 open-source programs. ExLi reduces 17,273 initially generated inline tests to 905 inline tests. The final set of generated inline tests kills up to 25.1% more mutants on target statements than developer written and automatically generated unit tests. That is, ExLi generates inline tests that can improve the fault-detection capability of the test suites from which they are extracted.

链接与引用

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

BibTeX
@inproceedings{Liu0G0L23,
  title = {Extracting Inline Tests from Unit Tests},
  author = {Yu Liu and Pengyu Nie and Anna Guo and Milos Gligoric and Owolabi Legunsen},
  booktitle = {ISSTA},
  year = {2023},
  doi = {10.1145/3597926.3598149}
}