Software Engineering basics - Test Case Design
What is Test Case Design?
Definition
Test Case Design is the process of creating a set of test cases (inputs, execution conditions, and expected results) that help ensure a software system meets its requirements and functions correctly.
The main goal is to find errors effectively and cover all possible scenarios — both valid and invalid.
Purpose of Test Case Design
-
To ensure complete test coverage of functionality.
-
To detect defects early in the software.
-
To verify that the system meets user and business requirements.
-
To make testing systematic and repeatable.
-
To reduce redundant tests while maintaining effectiveness.
What is a Test Case?
A test case is a document or specification that includes:
-
Test Case ID
-
Objective / Description
-
Preconditions
-
Test Steps
-
Input Data
-
Expected Result
-
Actual Result
-
Status (Pass/Fail)
Approaches to Test Case Design
There are mainly two broad categories of test case design techniques:
1. Black-Box Test Case Design Techniques
Focus on testing the functionality of the software without knowing the internal structure of the code.
2. White-Box Test Case Design Techniques
Focus on testing the internal logic and structure of the code.
1. Black-Box Test Case Design Approaches
| Approach | Description | Example |
|---|---|---|
| a. Equivalence Partitioning (EP) | Divides input data into valid and invalid partitions where all values in each partition behave similarly. | For an input range 1–100, test one valid (50) and one invalid (0 or 150). |
| b. Boundary Value Analysis (BVA) | Tests boundaries of input ranges, as errors often occur at the edges. | For input 1–100, test 0, 1, 100, and 101. |
| c. Decision Table Testing | Uses tables to represent combinations of conditions and their expected actions. | Login system: condition (username valid/invalid), (password valid/invalid). |
| d. State Transition Testing | Tests system behavior for valid and invalid state changes. | ATM: Card inserted → PIN entered → Balance checked → Card removed. |
| e. Use Case Testing | Derives test cases from use cases to ensure end-to-end functionality. | “Place Order” use case in an e-commerce system. |
2. White-Box Test Case Design Approaches
| Approach | Description | Example |
|---|---|---|
| a. Statement Coverage | Ensures every executable statement is run at least once. | Test all lines of code in a function. |
| b. Branch Coverage | Ensures every possible branch (true/false) of each decision is tested. | For if (x > 0), test with x = 5 and x = -3. |
| c. Condition Coverage | Ensures each Boolean condition is evaluated both true and false. | For if (A > 5 && B < 10), test all combinations of A and B. |
| d. Path Coverage | Ensures all possible execution paths are tested at least once. | Test every unique path through nested if-else conditions. |
| e. Loop Testing | Tests loops for zero, one, and multiple iterations. | For for(i=0; i<n; i++), test n=0, n=1, n>1. |
3. Experience-Based Test Case Design Approaches
| Approach | Description | Example |
|---|---|---|
| a. Error Guessing | Testers use experience and intuition to guess where defects are likely. | Entering special characters in input fields. |
| b. Exploratory Testing | Tester explores the system freely to discover defects. | Navigating an app without a predefined script. |
Diagram: Test Case Design Approaches
Here’s a simple conceptual diagram (text-based):
┌─────────────────────────┐
│ Test Case Design │
└────────────┬─────────────┘
│
┌──────────────────────────┼──────────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌────────────────┐ ┌────────────────┐
│ Black-Box │ │ White-Box │ │ Experience- │
│ Techniques │ │ Techniques │ │ Based Methods │
└──────┬────────┘ └──────┬─────────┘ └──────┬─────────┘
│ │ │
▼ ▼ ▼
EP, BVA, Decision Tables, Statement, Branch, Error Guessing,
State Transition, Use Case Condition, Path, Loop Exploratory Testing
Summary Table
| Category | Examples | Focus |
|---|---|---|
| Black-Box | EP, BVA, Decision Table | Functional behavior |
| White-Box | Path, Branch, Condition | Internal code structure |
| Experience-Based | Error Guessing, Exploratory | Tester’s intuition and experience |
Conclusion
-
Test case design ensures systematic and efficient testing.
-
Black-box techniques focus on what the system does.
-
White-box techniques focus on how it works internally.
-
Experience-based techniques use practical tester knowledge to find defects quickly.