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

往返变异测试:将代码转换为自然语言意图并返回

Round-Trip Mutation Testing: Translating Code to Natural Language Intent and back

University of Luxembourg(卢森堡大学);ENSI, University of Manouba(马努巴大学ENS学院)

Asma Hamidi, Cedric Richter, Ahmed Khanfir, Mike Papadakis

AI总结:

提出往返变异测试,利用大语言模型在程序代码和意图间的生成能力,通过预测意图生成变异体,还可人工制造错误翻译产生变异体,评估显示其能产生多样变异体,检测传统方法未揭示的错误。

摘要:

本文提出往返变异测试(RTM),一种从程序代码及其意图之间的大语言模型误译生成变异体的新方法。利用大语言模型在编程和自然语言之间的生成能力,给定输入程序,预测其意图以生成程序,不同的即为输出变异体。该方法还通过在最终程序(变异体)生成前变异意图产生变异体。通过评估,展示了往返变异测试产生语法上更多样变异体的潜力,可能暴露传统变异运算符未揭示的错误。更有趣的是,RTM在生成更小更强的测试套件方面优于传统基于模式的变异,分别仅选择4个和30个测试时,平均检测到的错误多4倍和1.7倍。

英文摘要:

This paper presents Round-Trip Mutation Testing (RTM), a novel approach that generates mutants from LLM mistranslations between a program code and its intent. Leveraging the generative capability of LLMs from and to programming and natural language, and given an input program, our approach predicts its intent, that is used to generate programs, which when different from the original one, constitute the output mutants. The approach produces additionally mutants, stemming from artificially provoked mistranslations, by mutating the intent prior to the final programs (mutants) generation. Originating from the propagation of small changes in the intent to the code, our intuition is that these programs would present subtle semantic differences from the original one, simulating likely-to-occur faults that could result from specification misunderstandings, and enabling mutation testing. To evaluate RTM, we run it on 40 real buggy methods and evaluate its effectiveness and cost-efficiency in guiding testing towards detecting the bugs. Our results demonstrate the potential of round-trip mutation testing to produce syntactically more diverse mutants, potentially exposing faults that traditional mutation operators fail to reveal. More interestingly, RTM outperforms traditional pattern-based mutation in producing smaller and stronger test-suites, detecting on average over 4 and 1.7 times more faults when selecting only 4 and 30 tests respectively.

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

↑