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

用于自动化Web表单测试生成的大语言模型:一项实证研究

Large Language Models for Automated Web-Form-Test Generation: An Empirical Study

Tao Li, Chenhui Cui, Rubing Huang, Dave Towey, Lei Ma

AI总结:

该研究针对Web表单自动化测试生成的上下文捕获难题,通过实证对比11种大语言模型在146个Web表单上的表现,提出三种HTML结构剪枝方法,验证了完整上下文提示对测试质量的提升作用,并给出模型选择与提示优化策略。

摘要:

Web表单测试是保障Web应用质量的核心工作,通常需要评估用户与表单之间的交互行为。自动化测试用例生成始终是Web表单测试领域的一大难题:由于Web页面存在复杂的多层级结构,自动化捕获其内在上下文信息并将其融入测试过程存在较大难度。大语言模型(Large Language Models, LLMs)已在上下文文本生成任务中展现出巨大潜力,这促使我们探索如何利用LLMs结合表单元素内的上下文信息,生成Web表单自动化测试。据我们所知,目前尚无针对不同LLM在Web表单测试生成任务中的对比研究。为填补这一文献空白,我们开展了一项全面的实证研究,在来自30个开源Java Web应用的146个Web表单上,调研了11种LLM的测试生成效果。此外,我们提出了三种HTML结构剪枝方法,用于提取关键上下文信息。实验结果表明,不同LLM的测试效果存在差异:与GPT-4相比,其余LLM难以生成适配Web表单的合理测试,它们的成功提交率(Successfully-Submitted Rates, SSRs)下降幅度在9.10%至74.15%之间。研究结果还显示,对于所有LLM而言,当设计的提示词包含完整清晰的Web表单上下文信息时,生成的Web表单测试效果更优。具体而言,使用“解析器处理的HTML作为任务提示(Parser-Processed HTML for Task Prompt, PH-P)”时,平均SSR达70.63%,高于“原始HTML作为任务提示(Raw HTML for Task Prompt, RH-P)”的60.21%,以及“LLM处理的HTML作为任务提示(LLM-Processed HTML for Task Prompt, LH-P)”的50.27%。最后,本文还总结了基于性能指标选择LLM、优化提示词设计以提升Web表单测试质量的策略。

英文摘要:

Testing web forms is an essential activity for ensuring the quality of web applications. It typically involves evaluating the interactions between users and forms. Automated test-case generation remains a challenge for web-form testing: Due to the complex, multi-level structure of web pages, it can be difficult to automatically capture their inherent contextual information for inclusion in the tests. Large Language Models (LLMs) have shown great potential for contextual text generation. This motivated us to explore how they could generate automated tests for web forms, making use of the contextual information within form elements. To the best of our knowledge, no comparative study examining different LLMs has yet been reported for web-form-test generation. To address this gap in the literature, we conducted a comprehensive empirical study investigating the effectiveness of 11 LLMs on 146 web forms from 30 open-source Java web applications. In addition, we propose three HTML-structure-pruning methods to extract key contextual information. The experimental results show that different LLMs can achieve different testing effectiveness. Compared with GPT-4, the other LLMs had difficulty generating appropriate tests for the web forms: Their successfully-submitted rates (SSRs) decreased by 9.10% to 74.15%. Our findings also show that, for all LLMs, when the designed prompts include complete and clear contextual information about the web forms, more effective web-form tests were generated. Specifically, when using Parser-Processed HTML for Task Prompt (PH-P), the SSR averaged 70.63%, higher than the 60.21% for Raw HTML for Task Prompt (RH-P) and 50.27% for LLM-Processed HTML for Task Prompt (LH-P). Finally, this paper also highlights strategies for selecting LLMs based on performance metrics, and for optimizing the prompt design to improve the quality of the web-form tests.

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

↑