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

TOGLL:利用大语言模型生成正确且强大的测试预言

TOGLL: Correct and Strong Test Oracle Generation with LLMs

Soneya Binta Hossain, Matthew Dwyer

AI总结:

本文提出TOGLL,一种基于大语言模型的测试预言生成方法,通过微调七个代码LLM并利用最优提示,在25个Java项目上生成正确、多样且强大的预言,检测出1,023个EvoSuite无法发现的独特缺陷,性能远超现有方法。

摘要:

测试预言在软件测试中扮演着至关重要的角色,能够实现有效的缺陷检测。尽管最初展现出潜力,基于神经网络的自动化测试预言生成方法往往导致大量误报和较弱的测试预言。虽然大语言模型(LLMs)在各类软件工程任务中已展现出令人瞩目的有效性,包括代码生成、测试用例创建和缺陷修复,但在测试预言生成方面,仍缺乏大规模研究来探索其有效性。LLMs能否应对有效预言生成中的挑战,这一问题既引人入胜又需要深入调查。在本研究中,我们首次全面探究了LLMs在生成正确、多样且强大的测试预言方面的能力,这些预言能够有效识别大量独特缺陷。为此,我们使用六种不同的提示(prompt)在SF110数据集上对七个代码LLM进行了微调。利用最有效的微调LLM与提示组合,我们提出了TOGLL,一种新颖的基于LLM的测试预言生成方法。为探究TOGLL的泛化能力,我们在25个大型Java项目上进行了研究。除了评估正确性,我们还评估了所生成预言的多样性和强度。我们将结果与EvoSuite及最先进的神经方法TOGA进行了比较。我们的发现表明,TOGLL能够生成比EvoSuite多3.8倍的正确断言预言和4.9倍的异常预言。此外,我们的研究证明TOGLL能够生成显著多样化的测试预言。它能检测出EvoSuite无法检测的1,023个独特缺陷,这一数量是先前最先进的基于神经的方法TOGA所能检测缺陷数量的十倍。

英文摘要:

Test oracles play a crucial role in software testing, enabling effective bug detection. Despite initial promise, neural-based methods for automated test oracle generation often result in a large number of false positives and weaker test oracles. While LLMs have demonstrated impressive effectiveness in various software engineering tasks, including code generation, test case creation, and bug fixing, there remains a notable absence of large-scale studies exploring their effectiveness in test oracle generation. The question of whether LLMs can address the challenges in effective oracle generation is both compelling and requires thorough investigation. In this research, we present the first comprehensive study to investigate the capabilities of LLMs in generating correct, diverse, and strong test oracles capable of effectively identifying a large number of unique bugs. To this end, we fine-tuned seven code LLMs using six distinct prompts on the SF110 dataset. Utilizing the most effective fine-tuned LLM and prompt pair, we introduce TOGLL, a novel LLM-based method for test oracle generation. To investigate the generalizability of TOGLL, we conduct studies on 25 large-scale Java projects. Besides assessing the correctness, we also assess the diversity and strength of the generated oracles. We compare the results against EvoSuite and the state-of-the-art neural method, TOGA. Our findings reveal that TOGLL can produce 3.8 times more correct assertion oracles and 4.9 times more exception oracles. Moreover, our findings demonstrate that TOGLL is capable of generating significantly diverse test oracles. It can detect 1,023 unique bugs that EvoSuite cannot, which is ten times more than what the previous SOTA neural-based method, TOGA, can detect.

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

↑