Use Case Testing: Deriving Tests from Actor Flows and Exceptions
Use case testing is a black-box technique that derives test cases directly from use cases — the structured descriptions of how actors interact with a system to achieve goals. It bridges requirements and test design without requiring testers to reverse-engineer intent from implementation.
The technique dates to Ivar Jacobson's work on use cases in the late 1980s, formalized in UML and widely adopted in enterprise software development through the 1990s and 2000s. Even in teams that don't write formal use cases today, the underlying concept — "what are all the ways a user can accomplish this goal, and what can go wrong?" — is directly applicable.
What Makes Use Case Testing Different
Most test design techniques focus on data: what inputs produce what outputs? Use case testing focuses on behavior over time: what sequence of interactions leads to what system state?
This is a fundamental shift. A user logging in isn't just a condition (correct password) and an effect (authenticated). It's a sequence:
- User navigates to login page
- User enters credentials
- System validates credentials
- System creates session
- System redirects to dashboard
Each step can fail in different ways. Each failure has a different recovery path. Use case testing captures this temporal dimension that purely data-driven techniques miss.
Anatomy of a Use Case
A well-formed use case has these components:
Use Case Name: UC-04: Transfer Funds Between Accounts
Primary Actor: Authenticated account holder
Preconditions: User is logged in. User has at least two accounts. Source account has a positive balance.
Main Success Scenario (Basic Flow):
- User selects "Transfer" from account menu
- User selects source account
- User selects destination account
- User enters transfer amount
- User confirms transfer
- System validates: sufficient funds, accounts in good standing, transfer within daily limit
- System debits source account
- System credits destination account
- System displays confirmation with transaction reference
- System sends confirmation email
Alternative Flows: Paths that deviate from the main flow but still succeed or gracefully handle situations.
Exception Flows: Paths where something goes wrong.
Postconditions: Source account balance reduced by transfer amount. Destination account balance increased by transfer amount. Transaction record created. Confirmation sent.
Deriving Test Cases: The Systematic Approach
Test 1: Main Success Scenario
The simplest test: walk through the basic flow exactly as described, with valid data at every step. Verify every postcondition.
Test: TC-04-01 Successful fund transfer
Preconditions: User logged in as "alice". Account A: $5,000 balance. Account B: $200 balance.
Steps:
1. Navigate to transfer page
2. Select Account A as source
3. Select Account B as destination
4. Enter amount: $500
5. Click "Confirm Transfer"
Expected:
- Account A balance: $4,500
- Account B balance: $700
- Transaction record created with reference number
- Confirmation email sent to alice@example.com
- Confirmation screen shows "Transfer complete" and reference numberThis is the happy path, and it's necessary. But it's only the starting point.
Test 2: Alternative Flows — Variations on Success
Alternative flows represent legitimate deviations from the main scenario that still succeed.
Alternative flow A: Transfer to external account (different bank) In step 3, user selects an external account. The flow continues similarly but:
- System must validate the external routing number
- Processing time may differ (3-5 business days instead of instant)
- Confirmation message reflects the delayed settlement
Test: TC-04-02 Transfer to external account
Preconditions: Alice has an external account linked (routing: 021000021, acct: 9876543210)
Steps:
4a. Select external account as destination
5-10. Same as main flow
Expected:
- Transaction created with status "pending" not "complete"
- Confirmation shows "Transfer will arrive in 3-5 business days"
- Balance deducted immediately from sourceAlternative flow B: Recurring transfer setup In step 5, instead of confirming one-time, user selects "Set as recurring monthly."
Test: TC-04-03 Set up recurring transfer
Expected:
- Recurring transfer record created
- Next scheduled date shown
- User can see it in "Scheduled Transfers" listTest 3: Exception Flows — When Things Go Wrong
This is where most of the interesting test cases live.
Exception E1: Insufficient funds
The system reaches step 6 and validation fails — source account has less than the requested transfer amount.
Test: TC-04-04 Transfer amount exceeds available balance
Preconditions: Account A balance: $100
Steps:
1-4. Standard flow
4. Enter amount: $500
5. Click "Confirm Transfer"
Expected:
- System displays error: "Insufficient funds. Available balance: $100.00"
- No debit occurs on Account A
- No credit occurs on Account B
- No transaction record created
- User remains on transfer page with amount field editableException E2: Daily transfer limit exceeded
Test: TC-04-05 Transfer exceeds daily limit
Preconditions: Daily limit is $1,000. User has already transferred $800 today.
Steps:
4. Enter amount: $300 (would bring daily total to $1,100)
Expected:
- Error: "Daily transfer limit exceeded. Remaining limit today: $200.00"
- Remaining limit is shown
- Transfer blockedException E3: Destination account in bad standing
Test: TC-04-06 Destination account frozen
Preconditions: Account B is frozen (regulatory hold)
Steps: Standard flow, Account B as destination
Expected:
- Error displayed after confirmation attempt
- Source account not debited
- Error message does NOT reveal reason for freeze (privacy/security)
- Generic message: "Transfer could not be completed. Please contact support."Exception E4: Session timeout during transfer
Test: TC-04-07 Session expires between entering amount and confirming
Steps:
1-4. Standard flow (enter amount)
[Wait for session to expire — or force expire via backend]
5. Click "Confirm Transfer"
Expected:
- User redirected to login page
- No transaction processed
- After re-login, user is not on transfer page with pre-populated data (security risk)
- Transfer must be re-entered from scratchTest 4: Postcondition Verification
Some testers check "did the UI say success?" and stop. Use case testing demands postcondition verification.
For TC-04-01:
- Query the database: is Account A's balance actually $4,500?
- Query the database: is Account B's balance actually $700?
- Check the email queue: was a confirmation email queued?
- Check the transaction log: is there a record with the correct amounts, accounts, and timestamp?
UI confirmation is a symptom, not evidence. Test the postconditions directly.
Test 5: Include/Extend Relationships
Use cases compose. "Transfer Funds" might include "Authenticate User" and might extend "Fraud Check."
For included use cases: the included flow is a prerequisite. Broken authentication should prevent access to transfer, not cause a broken state.
For extending use cases: the extension adds behavior under specific conditions.
Test: TC-04-08 Transfer triggers fraud review
Preconditions: First-time large transfer. User has never transferred more than $100.
Steps:
4. Enter amount: $4,999
Expected:
- Transfer initiates fraud review (extend: «Fraud Check»)
- Transfer placed in "pending review" state, not immediately processed
- User receives notification: "Your transfer is under review"
- Amount is held (locked) in source account, not deducted yetBuilding the Use Case Test Matrix
For each use case, build a test matrix before writing individual tests:
| Scenario | Type | Priority | TC |
|---|---|---|---|
| Successful transfer, same bank | Basic flow | High | TC-04-01 |
| Transfer to external account | Alt flow A | High | TC-04-02 |
| Set up recurring transfer | Alt flow B | Medium | TC-04-03 |
| Insufficient funds | Exception E1 | High | TC-04-04 |
| Daily limit exceeded | Exception E2 | High | TC-04-05 |
| Destination account frozen | Exception E3 | High | TC-04-06 |
| Session timeout during flow | Exception E4 | High | TC-04-07 |
| Large transfer triggers fraud review | Extension | Medium | TC-04-08 |
| Transfer to same account (self-transfer) | Exception | Medium | TC-04-09 |
| Amount: $0 | Exception | Low | TC-04-10 |
| Amount: negative number | Exception | Low | TC-04-11 |
| Amount: non-numeric input | Exception | Low | TC-04-12 |
| Concurrent transfer (same source account) | Exception | High | TC-04-13 |
| Source account in bad standing | Exception | High | TC-04-14 |
Before writing a single line of test steps, this matrix tells you: 14 test cases, 6 are high priority, 4 are the technical edge cases at the bottom. You can prioritize accordingly and defend your test selection to stakeholders.
Common Testing Blind Spots in Use Case Testing
Back buttons and browser navigation. The use case describes a forward flow. Users don't move forward. After step 6 (confirmation), a user pressing the browser back button and clicking "Confirm" again is not in the use case. It should be a separate test: verify that the back+resubmit doesn't double-transfer.
Concurrent execution. Two tabs, two devices, or two API calls hitting step 6 simultaneously. The use case describes a single actor. Real systems have concurrent actors. Add a concurrency test for any use case with a write operation.
Long-running flows. The use case flow looks instantaneous on paper. Steps 7 and 8 (debit/credit) might take 2 seconds. What happens if the user closes the browser during step 7? Are both operations atomic? The use case doesn't say. A good tester asks.
Actor assumptions. The use case says "authenticated user." But which type? A user with a read-only account? A joint account holder? A corporate account with spending limits? Each is a distinct precondition that may produce different behavior.
Use Cases Without Formal Documentation
Many teams don't write formal use cases. They have user stories, Jira tickets, wireframes, and Confluence pages. The technique still applies.
Convert informal descriptions into use case structure mentally:
User story: "As a user, I want to reset my password so I can regain access to my account."
Tester's analysis:
- Who are the actors? User with access to email. User who no longer has email access (different scenario).
- What's the main flow? Initiate reset → receive email → click link → enter new password → confirm → login with new password.
- What are alternative flows? Reset via SMS (if enabled). Reset via security questions (if enabled).
- What are exception flows? Email not received. Link expired. New password doesn't meet requirements. Old password reused. Link already used.
From that mental model, you derive the same test matrix. The use case structure is a thinking tool, not just a documentation format.
Mapping Use Case Tests to Automation
Use case tests are natural candidates for end-to-end automation:
class TestFundTransfer:
def test_successful_transfer_same_bank(self, authenticated_user, accounts):
# Setup
source = accounts.create(balance=5000, owner=authenticated_user)
dest = accounts.create(balance=200, owner=authenticated_user)
# Execute flow
transfer_page = app.navigate_to_transfer()
transfer_page.select_source(source)
transfer_page.select_destination(dest)
transfer_page.enter_amount(500)
confirmation = transfer_page.confirm()
# Verify postconditions
assert confirmation.reference_number is not None
assert accounts.get_balance(source) == 4500
assert accounts.get_balance(dest) == 700
assert email_queue.last_sent_to(authenticated_user.email).subject == "Transfer Confirmed"
def test_transfer_exceeds_balance(self, authenticated_user, accounts):
source = accounts.create(balance=100, owner=authenticated_user)
dest = accounts.create(balance=0, owner=authenticated_user)
transfer_page = app.navigate_to_transfer()
transfer_page.select_source(source)
transfer_page.select_destination(dest)
transfer_page.enter_amount(500)
error = transfer_page.confirm()
# Verify no side effects
assert "Insufficient funds" in error.message
assert "100.00" in error.message # Shows available balance
assert accounts.get_balance(source) == 100 # Unchanged
assert accounts.get_balance(dest) == 0 # Unchanged
assert transactions.count_today(source) == 0Each test method maps to one row in the use case test matrix. The structure is clear: setup preconditions, execute the flow, verify postconditions.
When Use Case Testing Is Most Valuable
Complex workflows with multiple actors. Order fulfillment: customer places order, warehouse picks and ships, customer receives and optionally returns. Three actors, three sub-use cases, multiple integration points. Use case testing keeps the scope clear.
Regulatory compliance. Healthcare, financial, and legal systems often have compliance requirements expressed as process descriptions. "The system SHALL provide the user with a 30-day warning before account closure AND SHALL record user acknowledgment." That's a use case with actors, flow, and postconditions.
System integration testing. When testing across system boundaries, use cases describe end-to-end behavior that crosses multiple APIs and services. The test follows the use case regardless of how many systems are involved.
User acceptance testing (UAT). Use cases are written in business language, which means non-technical stakeholders can review and validate them. "Does this test scenario match how you actually use the feature?" is a question a business analyst can answer. "Does this equivalence partition cover this boundary condition?" is not.
Use Case Testing vs Scenario Testing
These terms are often used interchangeably but have a distinction:
Scenario testing is broader and less structured — test scenarios are story-like descriptions of a complete usage situation, often written informally. "Alice is a power user who imports data weekly and has 10,000 records in her account. She exports to CSV and opens in Excel."
Use case testing is more formal — it follows documented use cases with explicit preconditions, flows, and postconditions.
In practice: use case testing is a specific form of scenario testing with a formal structure. Use scenarios for exploratory and integration testing; use use case tests for systematic coverage of documented requirements.
The Core Discipline
Use case testing enforces one discipline above all: test what the system is supposed to do, not just what inputs it receives.
A system that accepts a valid payment input and returns a 200 status code has been tested. A system that correctly charges the customer, updates the inventory, sends a confirmation, and handles the concurrent request that came in 50ms later without double-charging — that system has been use-case tested.
The flows, the alternatives, the exceptions, the postconditions. All of it.