Use Case Testing
Use case testing is a black-box test design technique that derives tests from use cases. A use case describes, step by step, how an actor — a user role or another system — interacts with the system to reach one goal: through a main flow (the usual path), alternative flows (other valid paths) and exception flows (what happens when something goes wrong). Every flow becomes at least one test.
Example: for "Place an online order", one test pays with a saved card along the main flow; another uses a card the payment gateway declines and checks that no order is created and nothing is charged. As in the lesson on test scenarios, each flow is a ready-made scenario; this technique finds all of them and makes coverage countable.
Why it matters
Users work through tasks, and tasks branch. Defects often hide where a flow branches, where it rejoins and in error handling: a customer charged twice after a timeout, an order created without payment, a cart emptied after a failed payment. Happy-path tests never visit these places, yet that is where failures cost money and trust.
For the tester, a use case turns a requirement into a countable list of scenarios. You can report "five of six checkout flows pass, the timeout flow fails" instead of "checkout mostly works", and reading a use case as a tester exposes missing flows before any code exists.
What a use case contains
In ISTQB terms, a use case is a sequence of interactions between an actor and the system with a tangible result. The actor can be a user or anything else that exchanges information with the system, and it is a role, not a person: "customer" or "payment gateway". The primary actor starts the use case to reach its goal; supporting actors are the people or systems needed on the way.
Names differ between templates — some teams call every branch an "extension" — but every branch must say where it leaves the main flow and where it ends. A typical use case has:
- Name: the goal as a verb phrase, such as "Place an online order".
- Precondition and trigger: what must be true before it starts, and the event that starts it.
- Main flow (also basic flow or main success scenario): the numbered steps of the usual path to the goal.
- Alternative flows: other valid paths with no error, usually ending at the same goal, such as paying with a new card.
- Exception flows: the system’s response when something goes wrong — invalid input, a business rule that blocks a step, a supporting system that refuses or does not answer. The flow either recovers, so the goal can still be reached, or ends the use case safely without the goal.
- Postconditions: what is true at the end, on success (order stored) and on failure (nothing charged, cart kept); the failure side is often forgotten.
Worked example: a checkout use case
A business analyst wrote this use case for an online shop. Read it as a tester: count the flows and note where each one leaves the main flow and where it ends.
There are six flows: the main flow, two alternative flows and three exception flows. E1 recovers into the main flow; E2 and E3 end without a paid order, so their tests must check what must not happen: a second payment request, a charge without an order, a lost cart.
UC-07 Place an online order
Primary actor: Customer (signed in)
Supporting actor: Payment gateway
Precondition: The cart holds at least one item in stock
Trigger: Customer selects "Checkout"
Main flow
1. System shows the items, the total and the saved delivery address.
2. Customer confirms the address.
3. Customer chooses the saved card and selects "Pay".
4. System sends one payment request; the gateway approves it.
5. System creates the order as Paid, reduces stock, empties the cart
and shows the order number.
Alternative flows
A1 at 2 Customer adds a new address; system validates it. Rejoins at 3.
A2 at 3 Customer enters a new card. Rejoins at 4.
Exception flows
E1 at 4 Gateway declines: system shows the reason. Back to 3.
E2 at 4 No reply within 30 s: system shows "Payment being confirmed",
records the order as Pending, sends no second request. Ends.
E3 at 5 An item sold out during payment: system voids the payment,
keeps the cart and tells the customer. Ends.- 1Show items, total and saved addressTrigger: the customer selects “Checkout”System
- 2Confirm the addressCustomer
Branch: A1 · alternative: new address, validated → rejoins at 3
- 3Choose the saved card and select “Pay”Customer
Branch: A2 · alternative: new card → rejoins at 4
- 4Send one payment request; the gateway approvesSystem + gateway
Repeats: E1 · exception: declined → reason shown → back to 3
Branch: E2 · exception: no reply in 30 s → order Pending, no second request; ends
- 5Create the order as Paid, reduce stock, empty the cartOrder number shownSystem
Branch: E3 · exception: item sold out → payment voided, cart kept; ends
Then:Goal reached: order Paid, stock reduced, cart empty
Dashed branches leave the main flow at the step where they start: alternative flows (A) still reach the goal, exception flows (E) handle something going wrong.
Deriving test cases from the flows
Each flow is a coverage item, so the minimum is one test per flow. A branch test follows the main flow to the branch point, triggers the branch and follows it to its end. If the branch rejoins further on, as A1 and A2 do, the test completes the main flow to show that the goal is still reached. If it loops back to an earlier step, as E1 does, the test checks that the actor is back at that step with nothing half done: no order, no charge.
- Precondition → test setup; trigger → first step; postconditions → expected results.
- Check data, not only the screen: the order status, the stock level and the payment record in the gateway’s test environment.
- Plan how to trigger every exception: a test card that the gateway’s sandbox (the test version of the service, run by the provider) always declines, a stub (a stand-in for the gateway that the team controls) that delays the reply, a second test user who buys the last item. A branch nobody can trigger quietly drops out of testing, so raise it early.
- Inside the steps, reuse earlier techniques: boundary values for the address fields, state transitions for the order status (Pending, Paid).
TC-07-01 Main: saved address and saved card
Expect: order Paid, stock reduced, cart empty, order number shown
TC-07-02 A1: new valid address at step 2
Expect: order Paid with the new address on it
TC-07-03 A2: new test card at step 3
Expect: order Paid with the new card
TC-07-04 E1: a sandbox card that the gateway declines
Expect: reason shown, back at step 3, no order, nothing charged
TC-07-05 E2: a stub delays the gateway reply beyond 30 s
Expect: message shown, order Pending, exactly one payment request sent
TC-07-06 E3: a second user buys the last unit during payment
Expect: payment voided, no order, cart kept, customer toldTry it: User Story → Test Scenarios Try it: Requirements → Test Scenarios
Use case coverage and its limits
Use case coverage is the number of flows exercised by at least one test divided by the number of flows identified, as a percentage. A suite that runs only the main flow, A1 and E1 covers 3 of the 6 flows of UC-07: 50%. The six tests above reach 100%.
Full flow coverage is the minimum. For risky use cases, add combinations, such as a decline followed by a new card (E1 then A2). And flow coverage says nothing about the flows nobody wrote, so ask at each step what else could happen:
- The actor cancels, goes back or waits until the session expires.
- The actor repeats an action: double-clicks "Pay" or refreshes during payment.
- A supporting system is slow, unavailable or answers twice.
- Another user changes the same data at the same moment.
Common mistakes
- Testing only the main flow and calling the use case done, although the branching and the error handling live in the other flows.
- Checking only the final screen instead of the postconditions in data, and, in exception flows, what must not have happened.
- Skipping exception flows as "hard to trigger" instead of agreeing early on test cards, stubs or data that make them reproducible.
- Walking several branches in one long test, so a failure does not show which flow broke and it is unclear which flows the test really covered. Give each flow its own test first.
- Stopping at flow coverage: one data value per flow ignores the inputs inside each step, which equivalence partitioning and boundary value analysis still need to cover.
The QA perspective
You will meet use cases in functional specifications written by business analysts. Review them before coding: is every step testable, does every branch say where it ends, are postconditions written for failure as well as success? Asking "what does the system guarantee when the goal is not reached?" often reveals an unwritten rule, such as how a timed-out payment is settled.
Name or tag each test with its use case and flow (UC-07/E2), so you can report coverage per use case and find the tests to update when the use case changes. A bug report then names the use case, the flow and the step: "UC-07 E2, step 4: a second payment request is sent after the timeout".
Practice exercise
Derive tests and measure coverage for a booking use case
A clinic app has the use case below. The team already has three tests: TC-21-01 (main flow), TC-21-02 (A1) and TC-21-03 (E1). Find what is missing, design the remaining tests and measure the use case coverage before and after.
UC-21 Book a clinic appointment
Primary actor: Patient (signed in)
Supporting actor: SMS service
Trigger: Patient selects "Book appointment"
Main flow
1. Patient chooses a clinic and a doctor.
2. System shows the doctor's free slots for the next 14 days.
3. Patient selects a slot and confirms.
4. System books the slot, shows a booking number and asks the SMS
service to send a confirmation.
Postcondition: the slot is no longer free; the booking appears in
"My appointments".
Alternative flows
A1 at 1 Patient searches by specialty instead of by doctor. Rejoins at 2.
A2 at 3 Patient adds a note for the doctor before confirming. Rejoins at 4.
Exception flows
E1 at 2 No free slot in 14 days: system offers the waiting list. Ends.
E2 at 3 Another patient booked the slot a moment earlier: system says so
and shows the updated slots. Back to 2.
E3 at 4 SMS service unavailable: the booking is kept and shown; the system
retries the SMS later. Ends.- List every flow with its id, its branch point and its end.
- Calculate the coverage of the three existing tests.
- For each untested flow, write how you trigger it and the expected end state, on screen and in data.
- Write two situations the use case does not describe as questions for the business analyst.
Show the model answer
Flows: main; A1 (at 1, rejoins at 2); A2 (at 3, rejoins at 4); E1 (at 2, ends without a booking); E2 (at 3, back to 2); E3 (at 4, ends with the booking made — an exception flow is not always a failure for the actor). Six flows in total.
Coverage: 3 of 6 flows = 50% before; 6 of 6 = 100% after adding tests for A2, E2 and E3.
TC-21-04 (A2): add a note and confirm; expect a booking number on screen, the note stored with the booking and the slot no longer free. TC-21-05 (E2): two test patients select the same slot in two browsers and confirm one after the other; expect the message and updated slots for the second, and exactly one booking. TC-21-06 (E3): book with the SMS service replaced by an unavailable stub; expect the booking number and the booking in "My appointments", and the SMS sent once the stub is available again.
Possible questions: Is the slot held during step 3, and for how long? Can a patient book two appointments at the same time?
Frequently asked questions
What is the difference between a use case and a user story?
A user story is a short statement of a need, with acceptance criteria, meant to start a conversation and to fit in one iteration. A use case describes the whole interaction step by step, including its alternative and exception flows. A team may split one use case into several stories; you can derive tests from either, but a use case lists the branches for you.
Is use case testing part of the ISTQB Foundation syllabus?
Not as a separate technique any more. CTFL v4.0 lists four black-box techniques: equivalence partitioning, boundary value analysis, decision table testing and state transition testing. Use case testing was one of the black-box techniques in the 2018 syllabus, and the ISTQB glossary still defines it. It remains useful wherever requirements are written as use cases.
How many tests does a use case need?
At least one per flow, which gives 100% use case coverage. Then add tests for risky combinations and loops, and data variations inside the steps using techniques such as equivalence partitioning and boundary value analysis.
References
- ISTQB GlossaryThe standard definitions of testing terms — test case, regression testing, severity, priority, boundary value analysis and the rest.
- ISTQB Certified Tester Foundation Level (CTFL) v4.0The foundation syllabus of software testing: test levels and types, test design techniques, test management and tools.
Practise with Mutqan tools
Derive end-to-end test scenarios from a user story, including alternate and exception flows.
Derive test scenarios from functional requirements with coverage mapping.
Generate high-level test scenarios covering functional, negative, security, usability and compatibility angles for a feature.
Convert a list of numbered requirements into traceable test cases with a requirement-to-test matrix.
Go deeper
Your progress on this topic
Not started
Mark the topic complete when you have studied it and done the exercise.
Sign in to track your progress
Mark topics complete, continue where you left off and unlock specialisation exams.