LLM-Based Test Case Generation Workflow: From Requirements to Spreadsheet Export
Generating test cases with a large language model is not a one-shot prompt. This article describes an end-to-end workflow that moves from requirement input and document extraction to test point generation, test point review, test case drafting, structural validation, and spreadsheet export. It explains how to define task boundaries, preserve requirement structure during extraction, separate test points from execution steps, constrain prompts, standardize case fields, and combine deterministic checks with human review. It also covers exception branches, safe file conversion, and metrics for evaluating real benefits. The goal is to help test teams use LLMs to reduce repetitive reading and formatting work while keeping coverage, traceability, and execution feasibility under human control.
1. A Complete Workflow Is Key to More Efficient Test Case Writing
Test case writing typically involves reading requirements, clarifying business rules, splitting test points, designing test data, organizing steps, and consolidating results. When people do this work manually, the most time-consuming part is often not typing. It is extracting verifiable rules from scattered requirement descriptions and maintaining coverage completeness and consistent expression across cases.
Large language models can assist with text understanding, rule summarization, and structured generation. However, if a requirement document is simply handed to a model with the instruction “generate all test cases,” the results tend to have three problems: first, conditions and exceptions in the requirements are missed; second, the output looks complete but lacks clear expected results; third, similar scenarios are generated repeatedly, increasing review cost.
A more reasonable approach is therefore not to rely on a single question-and-answer interaction, but to decompose the task into a checkable, traceable workflow:
Requirement input → document extraction → test point generation → test point review → test case generation → structural validation → spreadsheet export
In this workflow, the model supports analysis and drafting, deterministic programs handle format checks and file conversion, and testers confirm requirement interpretation, business risk, and execution feasibility. Only with clear division of labor can teams avoid mistaking generation speed for test quality.
2. Start Node: Define Inputs and Task Boundaries
2.1 Accept both documents and supplementary instructions
The start node of the workflow should provide at least two types of input: requirement files and user supplementary requirements.
Requirement files provide business context, functional descriptions, API constraints, or acceptance criteria. Supplementary requirements limit the scope of this generation run, for example, “generate only functional test cases for the new feature,” “focus on permission control and exception paths,” or “output using the team’s standard fields.”
If the orchestration environment provides built-in file variables and user input variables, they can be bound to downstream nodes separately. sys.files and sys.query in the original flow can be understood as example identifiers for these two types of input. Actual names, data types, and file handling methods should follow the definitions of the environment in use; do not assume that every environment has the same variables.
2.2 Check input quality early
At the input stage, check whether files are empty, whether content is readable, and whether the requirement version is clear. When multiple versions exist for the same feature, specify which version is the primary basis to prevent the model from mixing historical rules with new rules.
Sensitive information should also be checked. When real user data, access credentials, or internal business secrets are involved, data should be masked according to the organization’s data management requirements, and permissions for document upload, processing, and result storage should be controlled.
The goal of this stage is not to generate cases immediately, but to ensure that downstream nodes use correct, complete, and permitted materials.
3. Document Extraction Node: Turn Raw Files into Analyzable Requirement Text
3.1 Extract text and preserve necessary structure
The document extractor converts input files into text that downstream models can process. In addition to the body text, it should preserve heading hierarchy, table fields, section numbering, clause numbering, and source locations where possible.
For example, “the amount range is 1 to 5000, including boundary values” and “the amount range is 1 to 5000, excluding boundary values” correspond to different test data. If qualifiers are lost during extraction, incorrect cases may be generated even when the model’s reasoning process is correct.
After extraction, therefore, check the following:
- Whether business conditions are fully preserved;
- Whether table row and column relationships are clear;
- Whether units, ranges, default values, and enumeration values are accurate;
- Whether key rules in images have been converted into verifiable text;
- Whether there is garbled text, broken lines, or disordered order.
Image-based materials require a processing step with the appropriate recognition capability. If the current environment cannot reliably recognize them, prompt for human supplementation instead of assuming that image content has already been parsed.
3.2 Process long documents in segments and consolidate consistently
When requirements exceed the model’s context length, split them by business module or chapter rather than simply truncating by a fixed character count. During splitting, keep the conditions, behavior, and results of the same rule within one segment as much as possible.
Each segment can include a source ID, section name, and requirement version. During consolidation, check cross-section dependencies, such as whether role permissions defined in an earlier chapter affect an operation flow in a later chapter.
Segmented processing reduces input size, but it may also lose global relationships. An overall consistency check is therefore still needed.
4. Test Point Generation Node: Analyze Coverage Before Writing Execution Steps
4.1 Test points are the intermediate layer between requirements and test cases
Test points describe what needs to be verified, while test cases describe how to verify it and what result counts as a pass. Separating the two allows teams to check requirement coverage first and then expand execution details.
For example, if a requirement states that “only users with approval permission can perform approval operations,” the following test points can be derived:
- A user with the required permission can perform approval;
- A user without the required permission cannot perform approval;
- An unauthenticated user cannot perform approval;
- After a permission change, access control follows the specified effective rule.
The last item requires special attention. If the requirement does not state when a permission change takes effect, it should be marked as an open question rather than written as “effective immediately” by assumption.
4.2 Prompts should constrain the model’s analysis behavior
The test point generation node can use a task constraint such as:
“You are a test analyst. Extract test points only from the provided requirement text, covering normal flows, exception flows, boundary conditions, permission restrictions, and state changes. Each test point must be linked to a requirement source. Do not output behavior not specified in the requirements as a definite rule; list ambiguities, missing conditions, and open questions separately.”
Suggested output fields include:
- Test point ID;
- Functional module;
- Related requirement ID or source location;
- Verification objective;
- Scenario type;
- Known constraints;
- Open questions.
In node orchestration, the text output of the document extraction node should be explicitly passed to the model. Selecting “previous node output” in the interface does not necessarily mean the content has entered the model’s actual input. Check whether variable binding is effective through run records.
User supplementary requirements can constrain the task but must not override requirement facts. For example, if the user asks to “focus on boundary conditions,” that means adding boundary analysis, not removing necessary normal-flow verification.
5. Test Case Generation Node: Use Both Test Points and Original Requirements
5.1 Do not use test points as the sole input
Test points are usually summarized and may omit details from the original requirements. If the test case generation node receives only test points, the model may lack field rules, state conditions, and specific prompt requirements.
A safer input combination is:
Confirmed test points + corresponding requirement excerpts + user supplementary requirements + test case field specification
This controls the generation scope while preserving the factual basis. For long documents, retrieve or select the relevant requirement excerpts for each test point instead of repeatedly sending all content.
5.2 Standardize case fields and expression requirements
It is recommended that each case contain the following fields:
| Field | Writing requirement |
|---|---|
| Case ID | Unique and stable for review and traceability |
| Related test point | Clearly maps to one or more test points |
| Case title | Concisely describes the object and condition being verified |
| Preconditions | Describes account, state, environment, and dependencies |
| Test data | Provides data that can be prepared and distinguished |
| Steps | Numbered in execution order; avoid ambiguous expressions |
| Expected result | Describes an observable, judgeable result |
| Priority | Determined by business impact and risk |
| Requirement source | Preserves the requirement ID or section location |
| Open questions | Identifies items that cannot be determined from the requirements |
Expected results should avoid non-judgeable expressions such as “the function works normally” or “meets expectations.” For example, when the requirement already specifies a length limit, the expected result can be described as: “After the input exceeds the specified length, submission is rejected and no new record is created.” When exact prompt text is not specified by the requirement, fixed wording should not be invented.
5.3 Use test design methods rather than mechanically increasing quantity
The model can organize scenarios using general methods such as equivalence partitioning, boundary value analysis, decision tables, and state transitions.
For input limits, distinguish valid and invalid data and verify upper and lower boundaries. For multi-condition business rules, organize condition combinations. For features with state transitions, cover allowed and forbidden transitions.
However, do not combine all dimensions without limit. Prioritize high-risk rules, critical paths, and important interactions between conditions, and avoid generating large numbers of low-value, hard-to-maintain duplicate cases. Concurrency, security, and performance testing require explicit environments, loads, observation metrics, and pass criteria; an executable plan cannot be formed from a statement such as “verify system stability” alone.
6. Quality Validation Node: Check Generated Results Before Export
6.1 Separate format validation from content validation
Format validation is suitable for deterministic programs, such as checking for duplicate IDs, empty required fields, valid step structure, and whether related test points exist.
Content validation requires a combination of rules, model-assisted review, and human judgment. Focus on:
- Whether every confirmed test point has a corresponding case;
- Whether cases contain rules not supported by the requirements;
- Whether preconditions are sufficient to support execution;
- Whether test data meets scenario requirements;
- Whether expected results can be judged directly;
- Whether there are duplicate cases with different IDs.
If a model is used for a second-pass review, require it to output specific issues and their basis rather than only a “pass” conclusion. Model review may still miss issues or repeat errors, and it cannot replace human review of high-risk scenarios.
6.2 Build exception branches
When document extraction fails, model output cannot be parsed, required fields are missing, or requirements contain major ambiguity, the workflow should enter an explicit exception branch.
For format errors, validation results can be fed back to the generation node for a limited number of corrections. For missing requirements, return an open-question list. For processing failures, preserve the necessary node state and error information to help locate the problem.
Do not retry indefinitely. Repeated calls increase cost and may not solve problems caused by insufficient information.
7. Spreadsheet Export: File Conversion Should Be Handled by Deterministic Programs
The last step of the original flow is to output test cases as a spreadsheet. Here it is important to distinguish between “the model generates table text” and “the workflow generates a real, openable workbook file.”
A recommended approach is to have the model output structured data first, and then use a file generation node or program to convert it into a common spreadsheet file. The model is responsible for content, while the conversion program is responsible for field mapping, column order, line breaks, file encoding, and worksheet organization.
The workbook can be divided into three worksheets:
- Test point list: used to check requirement coverage;
- Test case list: used for review and execution;
- Open questions: used to track requirement clarifications.
During export, potential formula content in cells should also be handled. If text from documents or models starts with formula-triggering characters, it should be safely handled according to the file format and write method in use, preventing spreadsheet software from interpreting the text as a formula.
After generation, check whether the file opens normally, whether record counts are consistent, whether long text is fully preserved, and whether IDs and requirement sources are lost. Download permissions and retention periods should also meet organizational requirements.
8. Implementation: Measure Real Benefits with Verifiable Metrics
When evaluating this type of workflow, do not only count the number of generated test cases or model response time. More valuable metrics include requirement coverage, manual modification effort, duplicate case ratio, number of open questions, review time, and defects found after test case execution.
Coverage must first have a clearly defined measurement basis. For example, teams can calculate “the proportion of confirmed test points linked to existing cases,” but this number cannot be directly equated with software quality, nor can it prove that no requirements are missing.
It is advisable to start with a pilot on features with a clear scope and relatively stable rules, and have testers review generated results side by side. Adjust document processing methods, prompts, field specifications, and validation rules based on actual problems, and record requirement versions, generation times, and review status.
Ultimately, the value of LLM-assisted test design lies in reducing repetitive reading, summarization, and formatting work, allowing testers to devote more energy to risk identification, complex business analysis, and result judgment. With “document extraction—test point analysis—test case generation—quality validation—file export” as the main line, and with human review retained at key stages, teams can build a maintainable and traceable test case generation workflow.
