arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2301.03543cs.SE
收藏

基于预训练语言模型的高效变异测试

Efficient Mutation Testing via Pre-Trained Language Models

Ahmed Khanfir, Renzo Degiovanni, Mike Papadakis, Yves Le Traon

摘要:

变异测试是一种成熟的基于故障的测试技术。它通过在被测程序中播种错误并要求开发人员编写揭示这些错误的测试来运行。这些测试有可能揭示大量的故障-那些与种子故障耦合的故障-因此被认为是重要的。为了达到这个目的,突变测试应该播种那些在开发人员容易理解的意义上是“自然的”和强的(有很高的机会揭示错误)。为了实现这一点,我们建议使用预先训练的生成语言模型(即CodeBERT),这些模型能够生成类似于开发人员的代码,这些代码的操作与目标代码类似,但不完全相同。这意味着模型有能力播种自然故障,从而提供执行突变测试的机会。我们实现了这个想法,通过实施$μ$ BERT,突变测试技术,执行突变测试使用CodeBert和经验评估它使用689错误的程序版本。我们的研究结果表明,$μ$ BERT的故障揭示能力是高于一个国家的最先进的突变测试(PiTest),产生的测试,有高达17%的故障检测潜力比PiTest。此外,我们观察到$μ$ BERT可以补充PiTest,能够检测到PiTest遗漏的47个错误,而与此同时,PiTest可以找到$μ$ BERT遗漏的13个错误。

英文摘要:

Mutation testing is an established fault-based testing technique. It operates by seeding faults into the programs under test and asking developers to write tests that reveal these faults. These tests have the potential to reveal a large number of faults -- those that couple with the seeded ones -- and thus are deemed important. To this end, mutation testing should seed faults that are both "natural" in a sense easily understood by developers and strong (have high chances to reveal faults). To achieve this we propose using pre-trained generative language models (i.e. CodeBERT) that have the ability to produce developer-like code that operates similarly, but not exactly, as the target code. This means that the models have the ability to seed natural faults, thereby offering opportunities to perform mutation testing. We realise this idea by implementing $μ$BERT, a mutation testing technique that performs mutation testing using CodeBert and empirically evaluated it using 689 faulty program versions. Our results show that the fault revelation ability of $μ$BERT is higher than that of a state-of-the-art mutation testing (PiTest), yielding tests that have up to 17% higher fault detection potential than that of PiTest. Moreover, we observe that $μ$BERT can complement PiTest, being able to detect 47 bugs missed by PiTest, while at the same time, PiTest can find 13 bugs missed by $μ$BERT.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑