How to Generate Test Cases from Requirements (Step by Step, with AI Help)
Generate test cases from requirements in 7 steps: find test conditions, apply EP, boundaries and decision tables, trace coverage, then use AI safely to draft and review. Worked example included.

The short answer: you do not generate test cases from a requirement in one jump. You first break the requirement into test conditions (the rules and behaviours that can be checked), then use test design techniques to choose concrete inputs, then write each case with preconditions, steps and an expected result, and finally check coverage with a traceability table. AI tools can speed up the drafting, but they work well only when you hand them the rules you extracted and tell them which techniques to apply.
This guide walks through the full method on one worked example, shows where AI fits and where it goes wrong, and ends with a practice exercise and answer.
Four terms you need first
| Term | Meaning | Example |
|---|---|---|
| Requirement | What the system must do, often a user story with acceptance criteria | "Users can apply one coupon at checkout" |
| Test condition | One checkable aspect of the requirement | "Expired coupons are rejected" |
| Test case | Preconditions, inputs, steps and an expected result that check a condition | "Apply SAVE10 dated yesterday, expect 'Coupon expired'" |
| Traceability | Links from each requirement to the cases that cover it | REQ-12 → TC-01 to TC-09 |
These follow the definitions in the ISTQB glossary. If the difference between a scenario and a case is still fuzzy, read test scenario vs test case with worked examples first.
The requirement we will use (illustrative)
This is a made-up but realistic story from an online shop:
REQ-12 Apply coupon at checkout
As a shopper, I want to apply a coupon code so that I get a discount.
Acceptance criteria:
1. Only one coupon per order.
2. SAVE10 gives 10% off carts from Rs 500 to Rs 5,000 (inclusive).
3. Discount is capped at Rs 300.
4. Expired coupons show "Coupon expired".
5. Codes are not case-sensitive.
6. Guests must sign in before applying a coupon.Step 1: Read the requirement and ask questions
Before writing a single case, list what is unclear. Every unanswered question becomes a guessed expected result later. For REQ-12:
- What message appears for a cart of Rs 499?
- Is the cap applied before or after tax and shipping?
- If items are removed after the coupon is applied and the cart drops below Rs 500, is the coupon removed?
- Does "expired" mean after midnight of the expiry date, and in which time zone?
Send these to the product owner and record the answers next to the story. For this example, assume: below Rs 500 shows "Minimum cart Rs 500", the cap applies to the item subtotal, removing items re-checks the coupon, and expiry is end of day in IST.
Step 2: Extract test conditions
Turn every rule, input and output into a short condition. Include what the requirement implies, not only what it says.
- Valid SAVE10 on an eligible cart gives 10% off
- Cart below the minimum is rejected
- Cart above the maximum is rejected
- Discount never exceeds Rs 300
- Second coupon on the same order is rejected
- Expired coupon is rejected with the right message
- Code works in any letter case
- Guest is asked to sign in
- Removing items re-checks eligibility
- Unknown code is rejected (implied)
Step 3: Apply test design techniques to choose values
Techniques stop you from writing twenty cases that all test the same thing. Use the one that matches the shape of each condition.
Equivalence partitioning and boundary values for cart total
Partitions: below Rs 500 (invalid), Rs 500 to 5,000 (valid), above Rs 5,000 (invalid). With two-value boundary analysis, test 499, 500, 5,000 and 5,001. Add one mid value such as 2,000 for the normal case.
Boundary for the discount cap
10% reaches Rs 300 at a cart of Rs 3,000. Test 2,990 (discount 299), 3,000 (300) and 3,010 (still 300, not 301).
Decision table for who can apply what
| Rule | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| Signed in | Y | Y | Y | N |
| Coupon valid and not expired | Y | Y | N | - |
| Coupon already applied | N | Y | - | - |
| Result | Discount applied | "Only one coupon per order" | Error message | Sign-in prompt |
State transition for the cart
The coupon moves between Not applied, Applied and Removed. Removing items so the total falls to Rs 450 should move it from Applied to Removed with a message. That transition is easy to miss when reading the story top to bottom.
Our interactive test case design guide covers each technique in more depth.
Step 4: Write the test cases
Each case needs an ID, a title that says what is checked, preconditions, steps with real data, and one clear expected result. Here is a subset:
| ID | Title | Preconditions | Steps / data | Expected | Priority |
|---|---|---|---|---|---|
| TC-01 | Valid coupon at minimum cart | Signed in, cart Rs 500 | Apply SAVE10 | Discount Rs 50, total Rs 450 | High |
| TC-02 | Cart just below minimum | Signed in, cart Rs 499 | Apply SAVE10 | "Minimum cart Rs 500", no discount | High |
| TC-03 | Cart at maximum | Signed in, cart Rs 5,000 | Apply SAVE10 | Discount Rs 300 (capped) | High |
| TC-04 | Cart just above maximum | Signed in, cart Rs 5,001 | Apply SAVE10 | Coupon rejected | Medium |
| TC-05 | Cap just above threshold | Signed in, cart Rs 3,010 | Apply SAVE10 | Discount Rs 300, not Rs 301 | High |
| TC-06 | Second coupon rejected | SAVE10 already applied | Apply FLAT50 | "Only one coupon per order" | High |
| TC-07 | Expired coupon | Coupon expired yesterday | Apply it | "Coupon expired" | High |
| TC-08 | Lower-case code | Signed in, cart Rs 1,000 | Apply save10 | Discount Rs 100 | Low |
| TC-09 | Guest user | Not signed in | Apply SAVE10 | Sign-in prompt, no discount | Medium |
| TC-10 | Cart drops below minimum | SAVE10 applied on Rs 600 | Remove an item worth Rs 150 | Coupon removed with message | High |
For layout and wording rules, see test case writing best practices and the test case template guide.
Step 5: Check coverage with a traceability table
| Acceptance criterion | Test cases | Covered? |
|---|---|---|
| 1. One coupon per order | TC-06 | Yes |
| 2. 10% off Rs 500 to 5,000 | TC-01 to TC-04 | Yes |
| 3. Cap Rs 300 | TC-03, TC-05 | Yes |
| 4. Expired message | TC-07 | Yes |
| 5. Not case-sensitive | TC-08 | Yes |
| 6. Guests sign in | TC-09 | Yes |
| Implied: unknown code | none | Gap |
The table immediately shows the missing "unknown code" case. Add TC-11 for it. When the requirement changes later, the same table tells you which cases to update.
Step 6: Add negative, non-functional and edge cases
Requirements describe what should happen. Testers also check what should not. Consider:
- Input abuse: very long codes, spaces before or after the code, special characters.
- Concurrency: applying the same single-use coupon in two browser tabs at once.
- Security: can the discount be changed by editing the request? Our API Playground is a safe place to practise that kind of request-level check.
- Accessibility: is the error message announced to screen readers and visible without colour alone?
Add only the ones that match real risk. Not every story needs a security case, but money-related stories usually do.
Step 7: Review and prioritise
Ask a developer or the product owner to review the cases for ten minutes. They often spot a wrong expected result or a rule you misread. Then mark priority by risk: cases where money, data or access can go wrong are High. If time is short, run High first.
Using AI to generate test cases from requirements
Large language models such as ChatGPT, Claude, Gemini or Copilot can turn the work above into a first draft in seconds. They fail in predictable ways when given only a story title: generic cases, invented limits, and confident but wrong expected results. The fix is to do steps 1 and 2 yourself and give the model your clarified rules.
A prompt that follows the method
You are a senior QA engineer.
Requirement and clarified rules:
[paste REQ-12 with acceptance criteria and the answers from Step 1]
Tasks:
1. List the test conditions you see. Mark any you inferred.
2. For numeric rules, apply equivalence partitioning and two-value
boundary value analysis. Show the partitions and boundaries.
3. Build a decision table for sign-in, coupon validity and coupon
already applied.
4. Write test cases as a table:
ID | Title | Preconditions | Steps/data | Expected | Priority | Criterion
5. Do NOT invent rules. If something is unclear, list it as a question.How to review an AI draft
- Check every expected result against the requirement. Recalculate discounts yourself.
- Look for invented rules ("maximum 3 attempts") that are not in the story.
- Confirm boundaries are exact: 499/500 and 5,000/5,001, not "around 500".
- Check the traceability column: does every criterion have a case?
- Remove duplicates that test the same partition.
Tool-specific prompt guides: ChatGPT test case generation. Before pasting real requirements anywhere, check your company's policy on which AI tools are approved for internal documents.
Manual vs AI-assisted: when to use which
| Situation | Better approach | Why |
|---|---|---|
| Learning test design or preparing for interviews | Manual | You need to show the reasoning yourself |
| Clear story with numeric rules | AI draft + review | Fast, and boundaries are easy to verify |
| Vague or one-line requirement | Manual questions first | AI will fill gaps with guesses |
| Confidential or regulated domain | Manual or approved internal tool | Data policy and audit needs |
| BDD team writing Gherkin | AI draft of scenarios + team review | See the Gherkin reference for syntax |
Common problems and how to fix them
| Symptom | Likely cause | Fix |
|---|---|---|
| Too many cases, little coverage | Many values from one partition | Apply EP and keep one value per partition plus boundaries |
| Developers dispute expected results | Rules guessed, not confirmed | Do Step 1 and record answers on the story |
| Bugs found in production at edges | No boundary cases | Add two-value or three-value boundary tests |
| AI draft looks complete but misses flows | Model only saw the happy path | Give it states and roles, ask for a decision table |
| Cases become outdated quickly | No traceability | Keep the criterion column and update when stories change |
Practice exercise (with answer)
Requirement: "A password must be 8 to 20 characters and contain at least one digit. After 5 wrong attempts the account is locked for 15 minutes."
Write the boundary values for length, the decision table conditions, and the state transitions before you read the answer.
Show answer
- Length boundaries (two-value): 7, 8, 20, 21 characters, each with a digit.
- Digit rule: a 10-character password with no digit is rejected; one with a digit is accepted.
- Decision table conditions: length valid (Y/N), contains digit (Y/N); only Y/Y is accepted.
- Attempts boundary: 4 wrong attempts leave the account open; the 5th locks it.
- States: Active → Locked (5th wrong attempt) → Active (after 15 minutes). Invalid transition test: correct password while Locked is still refused.
- Question to ask: do the 5 attempts reset after a successful login?
Next step
Pick one story from your current project or a public app and run the seven steps on it, ending with a traceability table. If you want structured practice on the techniques, the free ISTQB Foundation course teaches equivalence partitioning, boundary values, decision tables and state transitions with exercises. Share your cases in the QA Community for feedback from other testers.
Key takeaways
- 1Test cases come from test conditions, and test conditions come from the rules, inputs and outputs in a requirement.
- 2Test design techniques decide which values to test, so you get good coverage with few cases.
- 3Ask questions before writing cases: a vague requirement produces vague or wrong expected results.
- 4A simple traceability table shows which requirement each case covers and exposes gaps.
- 5AI is a fast drafting assistant, not an oracle: give it the extracted rules, name the techniques, and review every expected result.
Common mistakes to avoid
- Writing test cases straight from the requirement title without listing its rules first.
- Testing many values from the same partition and missing the boundaries.
- Copying AI-generated expected results without checking them against the requirement.
- Ignoring negative, permission and state-based cases because the requirement only describes the happy path.
- Pasting confidential requirements into public AI tools against company policy.
