A Practical Guide to Building an AI Workflow for Test Case Generation
This article explains how to build an automated test case generation workflow that combines large language models with a visual, node-based canvas. It covers why manual test case writing becomes a bottleneck, a five-layer architecture (ingestion, parsing, cognition, generation, and rendering), implementation details for each key node with sample system prompts, debugging and acceptance methods, and engineering recommendations for production use. Readers will learn how to structure input contracts, control model hallucination, enforce consistent output formats, and keep human review in the loop.
1. Why Test Case Writing Becomes a Bottleneck
In the software delivery lifecycle, test cases are the bridge between requirements and quality. Yet in most teams, writing them still depends on manual effort: testers read through requirement documents page by page, interpret business rules, break down boundary conditions, and then fill in preconditions, steps, and expected results according to a fixed template. This process has three typical pain points.
First, high information density and repetitive work. A medium-sized requirement document often contains dozens of features and over a hundred business rules. Converting them one by one by hand makes omissions almost inevitable. Second, strict formatting constraints and high migration cost. Test cases must be saved as spreadsheet files so they can be imported into test management platforms. Field specifications, enumerated values, and continuous numbering are all mandatory, and maintaining the spreadsheet manually consumes a large amount of time. Third, quality depends heavily on individual experience. Team members interpret the granularity of a “test point” differently, which leads to uneven coverage depth and frequent rework during review.
Introducing a large language model into this step is not about replacing the tester’s judgment. It is about handing the three mechanical stages—reading comprehension, structure extraction, and format rendering—to an automated pipeline, so people can focus on risk assessment and scenario design.
2. Overall Architecture: A Layered Design for a Visual Workflow
A usable automated test case generation pipeline can be abstracted into five layers, each with a single responsibility and independently replaceable:
- Ingestion layer: receives the uploaded requirement document and a natural-language request (for example, “generate test cases for the login module only”).
- Parsing layer: converts the document from binary or rich-text format into plain text that the model can consume.
- Cognition layer: the large language model understands the requirements and outputs a structured list of test points.
- Generation layer: the model is called again to expand each test point into a complete test case entry with all fields.
- Rendering layer: converts the structured result into a spreadsheet file for download or import into downstream systems.
On a platform that supports canvas-based orchestration, these five layers map directly to nodes: a start node, a document extraction node, two large language model nodes, a format conversion tool node, and a final reply node. Nodes pass data to each other through variable references, forming a directed acyclic graph.
3. Implementation Details of Key Nodes
3.1 Start Node and Input Contract
The start node must explicitly declare its input variables. Define at least two: a file-type variable to carry the uploaded document, and a text variable to carry the user’s additional instructions. The core principle here is the input contract comes first—decide which fields the downstream needs, then constrain the upstream accordingly, which avoids repeated rewiring later.
3.2 Document Parsing Node
The parsing node converts the uploaded file into text. The key configuration point is correct variable mapping: the input references the file variable from the start node, and the output is a block of plain text. Two engineering considerations apply. First, scanned documents lack an extractable text layer, so it should be agreed in advance that users upload a version with copyable text. Second, very long documents will exceed the model’s context window, so segmentation or summary preprocessing should be added after parsing; otherwise generation quality drops noticeably.
3.3 Test Point Extraction Node
The first model node’s task is to converge, not to expand. The system prompt should instruct the model to act as a test architect and output test points along the following dimensions:
Role: Senior test designerTask: Read the requirement text and extract verifiable test pointsOutput dimensions:1. Functional happy paths2. Parameter boundaries and value ranges3. Invalid inputs and error messages4. Permissions and data isolation5. State transitions and concurrency scenarios6. Compatibility and non-functional constraintsRequirement: Each test point includes an ID, the module it belongs to, a one-sentence description, and a priorityProhibited: Fabricating capabilities that do not exist in the requirements
The context variable references the text output of the parsing node, and the user variable references the natural-language request from the start node to limit the module scope. The “no fabrication” constraint is critical here; it is the first gate for controlling model hallucination.
3.4 Test Case Expansion Node
The second model node takes on the “expansion” role, refining each test point into an executable test case. The prompt must specify the table column structure and value rules:
Expand the input test points into test cases with fixed fields:Case ID | Module | Title | Preconditions | Test Steps | Expected Result | Priority | Case TypeRequirements:- Steps use ordered numbering 1. 2. 3., and each step describes only one action- Expected results must be observable and verifiable; avoid vague statements like "displays normally"- Case IDs are continuous and unique- Output a standard Markdown table with no extra explanatory text
Requiring the model to output a well-formed table rather than free text allows the downstream rendering step to parse it at zero cost. This is the dividing line for whether the whole pipeline runs reliably.
3.5 Format Conversion and Reply Nodes
The rendering step uses a spreadsheet conversion plugin from the platform’s tool view to turn the Markdown table into a spreadsheet file. Before use, search for and install the plugin in the tool view; only after installation can it be selected on the canvas. In the configuration, bind the input variable to the output of the previous node. Finally, connect a reply node that returns the generated file as an attachment, which the user can click to download.
4. Debugging and Acceptance
Do not publish immediately after orchestration. Open the feature management in preview mode, enable file upload, and set the allowed file types and size limits. Then run three groups of checks:
- Happy path: upload a well-structured requirement document, specify a single module, and check whether the case fields are complete and the IDs are continuous.
- Boundary path: upload a document with many tables and nested lists, and observe whether parsing is truncated.
- Adversarial path: request a feature that does not exist in the document, and verify whether the model refuses to fabricate it.
Acceptance metrics should be quantified: field completeness rate, ID uniqueness, proportion of verifiable expected results, and manual review pass rate. If any metric falls short, adjust the prompt constraints first, then consider splitting nodes into finer granularity.
5. Recommendations for Engineering Implementation
On general-purpose cloud capability systems such as Baidu AI Cloud, this kind of pipeline can be further productized: use object storage to archive requirement documents and generated results, use a message queue to smooth out bursts of batch tasks, use a container platform to host parsing and conversion services, and use logging and monitoring with alerting to track node failure rates and latency distribution. At the same time, keep a human review checkpoint—automation produces the first draft, while testers handle risk rating and scenario completion. This is the optimal balance between efficiency and quality.
