SE Notes
Systematic techniques for designing effective test cases.
Test case design is the art and science of creating test cases that effectively reveal defects while using minimal resources. A well-designed test suite achieves high defect detection with fewer test cases, while a poorly designed suite might execute thousands of tests yet miss critical bugs. The challenge is selecting, from an infinite space of possible tests, the finite subset most likely to expose defects. Systematic test design techniques replace ad-hoc "try random stuff" approaches with structured methods that ensure thorough coverage with justifiable confidence.
Anatomy of a Test Case
Every test case contains these essential elements:
| Element | Description | Example |
|---|---|---|
| Test Case ID | Unique identifier | TC-LOGIN-003 |
| Title | Brief description of what is tested | Verify login fails with wrong password |
| Preconditions | Required state before test execution | User account exists, user is on login page |
| Test Data | Specific input values | Email: user@test.com, Password: wrong123 |
| Steps | Exact actions to perform | 1. Enter email 2. Enter wrong password 3. Click Login |
| Expected Result | What should happen | Error message: "Invalid credentials" displayed |
| Actual Result | What actually happened (filled during execution) | [Filled during test execution] |
| Status | Pass/Fail/Blocked | [Determined after execution] |
| Priority | Importance level | High |
| Traceability | Links to requirements | REQ-AUTH-001 |
Test Design Techniques
Equivalence Class Partitioning
Divide the input domain into classes where the system should behave identically for all values within a class. Test one representative from each class.
Example: Email validation field
- Valid format class: "user@domain.com" (test one valid email)
- Missing @ class: "userdomain.com" (test one without @)
- Missing domain class: "user@" (test one without domain)
- Multiple @ class: "user@@domain.com" (test one with multiple @)
- Empty input class: "" (test empty string)
Boundary Value Analysis
Test at the exact boundaries of equivalence classes:
Example: Password length requirement (8-20 characters)
- Test length 7 (just below minimum → should fail)
- Test length 8 (at minimum → should pass)
- Test length 20 (at maximum → should pass)
- Test length 21 (just above maximum → should fail)
Decision Table Testing
For functions with multiple conditions affecting the output:
Example: Loan eligibility determination
| # | Income > 50K | Credit > 700 | Employed > 2yr | Result |
|---|---|---|---|---|
| 1 | Y | Y | Y | Approved |
| 2 | Y | Y | N | Conditional |
| 3 | Y | N | Y | Conditional |
| 4 | Y | N | N | Rejected |
| 5 | N | Y | Y | Conditional |
| 6 | N | Y | N | Rejected |
| 7 | N | N | Y | Rejected |
| 8 | N | N | N | Rejected |
Each row becomes a test case with specific values satisfying those conditions.
State Transition Testing
Design tests that exercise valid and invalid state transitions:
Example: Online order lifecycle
- Valid: Created → Confirmed → Shipped → Delivered (happy path)
- Valid: Created → Cancelled (cancel before confirmation)
- Invalid: Shipped → Created (cannot revert to created state)
- Valid: Delivered → Returned (within return window)
- Invalid: Delivered → Returned (after return window expires)
Pairwise (Combinatorial) Testing
When testing all combinations is impractical, pairwise testing ensures every pair of parameter values is tested in at least one test case:
Example: Testing a form with Browser (Chrome, Firefox, Safari), OS (Windows, Mac, Linux), and Language (English, Spanish, French) → 27 full combinations, but pairwise testing covers all pairs in just 9 test cases.
Real-World Example: Flight Search Test Cases
Designing test cases for an airline flight search feature:
| TC-FS-001 | Basic one-way search |
| Precondition | User is on search page |
| Input | Origin=JFK, Destination=LAX, Date=future date, Passengers=1 |
| Expected | List of available flights displayed with prices |
| TC-FS-002 | Round trip search |
| Input | Origin=JFK, Dest=LAX, Depart=Jan 15, Return=Jan 22, Passengers=2 |
| Expected | Outbound and return flight options displayed |
| TC-FS-003 | Same origin and destination |
| Input | Origin=JFK, Destination=JFK |
| Expected | Error "Origin and destination must be different" |
| TC-FS-004 | Past date search |
| Input | Date=yesterday |
| Expected | Error "Please select a future date" |
| TC-FS-005 | No flights available |
| Input | Valid route with no scheduled flights |
| Expected | "No flights available" message with alternative date suggestions |
Test Case Prioritization
Not all test cases are equally important. Prioritize based on:
- Business criticality: Tests for revenue-generating features rank higher
- Defect probability: Areas with history of bugs get more attention
- User frequency: Commonly used features tested more thoroughly
- Requirement stability: Recently changed requirements need more testing
- Failure impact: Features where failure causes data loss or security issues rank highest
Traceability Matrix
A requirements traceability matrix maps each requirement to its corresponding test cases, ensuring complete coverage:
| Requirement | Test Cases | Status |
|---|---|---|
| REQ-001: User login | TC-001, TC-002, TC-003 | Covered |
| REQ-002: Password reset | TC-010, TC-011 | Covered |
| REQ-003: Session timeout | TC-020 | Covered |
| REQ-004: Audit logging | — | NOT COVERED ⚠️ |
The matrix immediately reveals coverage gaps—REQ-004 has no tests, representing a quality risk.
Best Practices
Write test cases that are independent (not dependent on other test case outcomes), repeatable (same result every time), and maintainable (easy to update when requirements change). Include both positive tests (verifying correct behavior) and negative tests (verifying proper handling of invalid inputs). Document test data requirements clearly. Review test cases with developers and business analysts to catch misunderstandings early.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Test Case Design.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Software Engineering topic.
Search Terms
software-engineering, software engineering, software, engineering, testing, test, case, design
Related Software Engineering Topics