Software Engineering
LLMs Generate Control Flow Graphs to Automate Test Case Creation from Use Cases
A new approach leverages large language models to transform natural language use-case descriptions into structured control flow graphs, enabling more comprehensive and consistent automated test case generation.
Researchers have proposed LLMCFG-TGen, an end-to-end method that harnesses LLMs to automatically generate test cases from natural language use-case descriptions. The work addresses a longstanding challenge in software testing: deriving comprehensive and logically coherent test cases from unstructured requirements.
The Problem#
Requirements-Based Test Generation (RBTG) aims to verify that system behavior matches user needs and expectations by deriving test cases from software requirements. However, most requirements are written in plain language, making them difficult to analyze systematically. While prior LLM-based approaches have shown promise, they often struggle to ensure comprehensive coverage, capture complex conditional logic accurately, or avoid redundancy in test generation.
The Approach#
LLMCFG-TGen operates in three distinct steps:
-
CFG Generation: An LLM transforms a natural language use case into a structured JSON-based Control Flow Graph that explicitly captures all potential branches and execution paths.
-
Test-Path Extraction: The CFG is systematically traversed to derive all possible execution paths through the system behavior.
-
Test-Case Creation: Concrete test cases are generated from the extracted execution paths, ensuring coverage of the logic captured in the CFG.
This intermediate representation—the structured control flow graph—serves as a bridge between human-written requirements and systematic test generation, allowing the approach to handle complex conditional logic more effectively than prior LLM-only methods.
Results#
The researchers evaluated their approach across six use-case datasets spanning diverse application domains. Results demonstrate that LLMs can effectively construct structured CFGs from natural language descriptions, and that LLMCFG-TGen produces more complete and logically consistent test cases compared to two baseline approaches. Both automated LLM-based evaluation and review by practicing software engineers confirmed improvements in test comprehensiveness and logical coherence while reducing manual effort required for test case creation.
This work suggests that structuring the intermediate representation of requirements—rather than directly generating test cases—can significantly improve test quality in automated testing workflows.