LLMCFG-TGen:利用LLM生成的控制流图从用例自动创建测试用例
LLMCFG-TGen: Using LLM-Generated Control Flow Graphs to Automatically Create Test Cases from Use Cases
AI总结:
提出LLMCFG-TGen方法,通过LLM将自然语言用例转化为控制流图,提取执行路径并生成测试用例,解决现有方法覆盖不全和逻辑遗漏问题。
摘要:
适当的测试用例生成在软件测试中至关重要,并显著影响测试质量。基于需求的测试生成(RBTG)从软件需求中推导测试用例,以验证系统行为是否符合用户需求和期望。需求通常以自然语言(NL)记录,其中用例描述是一种以结构化、可读形式捕获功能行为和交互流程的流行方法。最近,大型语言模型(LLM)在从NL需求自动生成测试方面显示出强大潜力。然而,现有的基于LLM的方法往往无法确保全面且无冗余的覆盖,并且可能无法充分捕获复杂的条件逻辑,导致测试用例不完整。为解决这些局限性,我们提出了一种端到端方法,称为基于LLM生成的控制流图的测试生成(LLMCFG-TGen),该方法从NL用例描述生成测试用例。它包括三个步骤:(1)CFG生成,其中LLM将用例转换为基于JSON的结构化控制流图,捕获所有潜在分支;(2)测试路径提取,遍历CFG以推导执行路径;(3)测试用例创建,从这些路径生成测试用例。我们在跨不同领域的六个用例数据集上评估该方法。结果表明,LLM可以有效地从NL用例构建结构化CFG。与两个基线相比,LLMCFG-TGen通过更好地捕获行为逻辑和执行流程,生成更完整且结构一致的测试用例。基于LLM和从业者的评估进一步证实了改进的全面性和逻辑连贯性,同时减少了手动工作。
英文摘要:
Appropriate test-case generation is critical in software testing and significantly impacts testing quality. Requirements-Based Test Generation (RBTG) derives test cases from software requirements to verify whether system behavior aligns with user needs and expectations. Requirements are often documented in Natural Language (NL), with use-case descriptions being a popular method for capturing functional behaviors and interaction flows in a structured, readable form. Recently, Large Language Models (LLMs) have shown strong potential for automating test generation from NL requirements. However, existing LLM-based approaches often fail to ensure comprehensive and non-redundant coverage, and may not adequately capture complex conditional logic, leading to incomplete test cases. To address these limitations, we propose an end-to-end approach called Test Generation based on LLM-generated Control Flow Graphs (LLMCFG-TGen), which generates test cases from NL use-case descriptions. It consists of three steps: (1) CFG Generation, where an LLM transforms a use case into a structured JSON-based Control Flow Graph capturing all potential branches; (2) Test-Path Extraction, where the CFG is traversed to derive execution paths; and (3) Test-Case Creation, where test cases are generated from these paths. We evaluate the approach on six use-case datasets across diverse domains. Results show that LLMs can effectively construct structured CFGs from NL use cases. Compared with two baselines, LLMCFG-TGen produces more complete and structurally consistent test cases by better capturing behavioral logic and execution flows. Both LLM-based and practitioner-based evaluations further confirm improved comprehensiveness and logical coherence while reducing manual effort.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。