AugmenTest:利用LLM驱动的预言机增强测试
AugmenTest: Enhancing Tests with LLM-Driven Oracles
AI总结:
本文提出AugmenTest,利用LLM从文档推断测试预言机,在142个Java类和203个独特测试上评估,Extended Prompt达30%成功率,优于TOGA的8.2%。
摘要:
自动化测试生成对于确保软件应用程序的可靠性和鲁棒性至关重要,同时还能减少所需的工作量。尽管在测试生成研究方面取得了显著进展,但生成有效的测试预言机仍然是一个未解决的问题。为了应对这一挑战,我们提出了AugmenTest,这是一种利用大型语言模型(LLMs)根据被测软件的可用文档来推断正确测试预言机的方法。与大多数依赖代码的现有方法不同,AugmenTest利用LLMs的语义能力,从文档和开发者注释中推断方法的预期行为,而无需查看代码。AugmenTest包含四种变体:Simple Prompt、Extended Prompt、使用通用提示的RAG(不包含被测类或方法的上下文)以及使用Simple Prompt的RAG,每种变体向LLMs提供不同级别的上下文信息。为了评估我们的工作,我们选择了142个Java类并为每个类生成多个变异体。然后我们从这些变异体生成测试,仅关注在变异体上通过但在原始类上失败的测试,以确保测试有效地捕获了错误。这产生了203个具有不同错误的独特测试,随后用于评估AugmenTest。结果显示,在最保守的场景下,AugmenTest的Extended Prompt持续优于Simple Prompt,在生成正确断言方面达到了30%的成功率。相比之下,最先进的TOGA方法仅达到8.2%。与我们的预期相反,基于RAG的方法并未带来改进,在最保守的场景下成功率为18.2%。
英文摘要:
Automated test generation is crucial for ensuring the reliability and robustness of software applications while at the same time reducing the effort needed. While significant progress has been made in test generation research, generating valid test oracles still remains an open problem. To address this challenge, we present AugmenTest, an approach leveraging Large Language Models (LLMs) to infer correct test oracles based on available documentation of the software under test. Unlike most existing methods that rely on code, AugmenTest utilizes the semantic capabilities of LLMs to infer the intended behavior of a method from documentation and developer comments, without looking at the code. AugmenTest includes four variants: Simple Prompt, Extended Prompt, RAG with a generic prompt (without the context of class or method under test), and RAG with Simple Prompt, each offering different levels of contextual information to the LLMs. To evaluate our work, we selected 142 Java classes and generated multiple mutants for each. We then generated tests from these mutants, focusing only on tests that passed on the mutant but failed on the original class, to ensure that the tests effectively captured bugs. This resulted in 203 unique tests with distinct bugs, which were then used to evaluate AugmenTest. Results show that in the most conservative scenario, AugmenTest's Extended Prompt consistently outperformed the Simple Prompt, achieving a success rate of 30\% for generating correct assertions. In comparison, the state-of-the-art TOGA approach achieved 8.2\%. Contrary to our expectations, the RAG-based approaches did not lead to improvements, with performance of 18.2\% success rate for the most conservative scenario.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。