SoftwareTestPilot
AI in TestingPublished: Updated: · 1 week ago13 min read

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.

SoftwareTestPilot
QA Editorial Team
Share:XLinkedInWhatsApp
How to Generate Test Cases from Requirements (Step by Step, with AI Help): AI in Testing article cover, SoftwareTestPilot.com
How to Generate Test Cases from Requirements (Step by Step, with AI Help): AI in Testing article cover, SoftwareTestPilot.com

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

TermMeaningExample
RequirementWhat the system must do, often a user story with acceptance criteria"Users can apply one coupon at checkout"
Test conditionOne checkable aspect of the requirement"Expired coupons are rejected"
Test casePreconditions, inputs, steps and an expected result that check a condition"Apply SAVE10 dated yesterday, expect 'Coupon expired'"
TraceabilityLinks from each requirement to the cases that cover itREQ-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.

  1. Valid SAVE10 on an eligible cart gives 10% off
  2. Cart below the minimum is rejected
  3. Cart above the maximum is rejected
  4. Discount never exceeds Rs 300
  5. Second coupon on the same order is rejected
  6. Expired coupon is rejected with the right message
  7. Code works in any letter case
  8. Guest is asked to sign in
  9. Removing items re-checks eligibility
  10. 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

Rule1234
Signed inYYYN
Coupon valid and not expiredYYN-
Coupon already appliedNY--
ResultDiscount applied"Only one coupon per order"Error messageSign-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:

IDTitlePreconditionsSteps / dataExpectedPriority
TC-01Valid coupon at minimum cartSigned in, cart Rs 500Apply SAVE10Discount Rs 50, total Rs 450High
TC-02Cart just below minimumSigned in, cart Rs 499Apply SAVE10"Minimum cart Rs 500", no discountHigh
TC-03Cart at maximumSigned in, cart Rs 5,000Apply SAVE10Discount Rs 300 (capped)High
TC-04Cart just above maximumSigned in, cart Rs 5,001Apply SAVE10Coupon rejectedMedium
TC-05Cap just above thresholdSigned in, cart Rs 3,010Apply SAVE10Discount Rs 300, not Rs 301High
TC-06Second coupon rejectedSAVE10 already appliedApply FLAT50"Only one coupon per order"High
TC-07Expired couponCoupon expired yesterdayApply it"Coupon expired"High
TC-08Lower-case codeSigned in, cart Rs 1,000Apply save10Discount Rs 100Low
TC-09Guest userNot signed inApply SAVE10Sign-in prompt, no discountMedium
TC-10Cart drops below minimumSAVE10 applied on Rs 600Remove an item worth Rs 150Coupon removed with messageHigh

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 criterionTest casesCovered?
1. One coupon per orderTC-06Yes
2. 10% off Rs 500 to 5,000TC-01 to TC-04Yes
3. Cap Rs 300TC-03, TC-05Yes
4. Expired messageTC-07Yes
5. Not case-sensitiveTC-08Yes
6. Guests sign inTC-09Yes
Implied: unknown codenoneGap

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

  1. Check every expected result against the requirement. Recalculate discounts yourself.
  2. Look for invented rules ("maximum 3 attempts") that are not in the story.
  3. Confirm boundaries are exact: 499/500 and 5,000/5,001, not "around 500".
  4. Check the traceability column: does every criterion have a case?
  5. 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

SituationBetter approachWhy
Learning test design or preparing for interviewsManualYou need to show the reasoning yourself
Clear story with numeric rulesAI draft + reviewFast, and boundaries are easy to verify
Vague or one-line requirementManual questions firstAI will fill gaps with guesses
Confidential or regulated domainManual or approved internal toolData policy and audit needs
BDD team writing GherkinAI draft of scenarios + team reviewSee the Gherkin reference for syntax

Common problems and how to fix them

SymptomLikely causeFix
Too many cases, little coverageMany values from one partitionApply EP and keep one value per partition plus boundaries
Developers dispute expected resultsRules guessed, not confirmedDo Step 1 and record answers on the story
Bugs found in production at edgesNo boundary casesAdd two-value or three-value boundary tests
AI draft looks complete but misses flowsModel only saw the happy pathGive it states and roles, ask for a decision table
Cases become outdated quicklyNo traceabilityKeep 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

  1. 1Test cases come from test conditions, and test conditions come from the rules, inputs and outputs in a requirement.
  2. 2Test design techniques decide which values to test, so you get good coverage with few cases.
  3. 3Ask questions before writing cases: a vague requirement produces vague or wrong expected results.
  4. 4A simple traceability table shows which requirement each case covers and exposes gaps.
  5. 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.

Frequently asked questions

1.What is the first step to generate test cases from requirements?
Read the requirement and list questions about anything unclear, then extract test conditions. Writing cases before this usually produces guessed expected results.
2.Which techniques are used to derive test cases from requirements?
Equivalence partitioning and boundary value analysis for ranges, decision tables for combinations of rules, state transition testing for workflows, and experience-based techniques such as error guessing for edge cases.
3.Can AI generate test cases from requirements on its own?
It can draft them, but it cannot confirm unclear rules or know your business context. Give it clarified rules, name the techniques, and review every expected result yourself.
4.How many test cases does one requirement need?
There is no fixed number. Use enough to cover every partition, boundary, rule combination and state change that carries risk, and check with a traceability table that every acceptance criterion is covered.