Unit 2 white box and types
Unit 2 white box and types
White Box Testing is a test case design approach that requires knowledge of the internal structure,
code, and logic of the software. It helps in verifying the flow of execution, logic errors, and internal
paths of the program.
1. Statement Coverage
Example:
If the code has an if-else condition, statement coverage ensures both the if block and else block are
executed at least once.
• Ensures that each decision point (if, switch, loops) has been executed in both true and false
conditions.
Example:
For an if-else statement, both outcomes (true & false) must be tested:
CopyEdit
if (x > 5)
print("Greater");
else
print("Smaller");
Test Cases:
1. x = 6 (True condition)
2. x = 3 (False condition)
3. Condition Coverage
• Ensures that each Boolean condition inside a decision statement is tested for both true and
false values.
Example:
For a condition if (A && B), test cases must cover:
1. A = True, B = False
2. A = False, B = True
3. A = True, B = True
4. A = False, B = False
Example:
For if (A || B), test cases should cover:
1. A = True, B = False
2. A = False, B = True
3. A = True, B = True
4. A = False, B = False
5. Path Coverage
Example:
If a function has three possible paths, test cases must cover all three execution flows.
6. Loop Testing
• Test Case Goal: Check loop behavior with different input values.
• Test Cases Should Include:
o One iteration
o Multiple iterations
o Maximum limit
o Exceeding limit
Example:
For a loop:
CopyEdit
print(i);
Test Cases:
2. i = 1 (Single iteration)
3. i = 5 (Multiple iterations)
4. i = 10 (Max iterations)
5. i = 11 (Beyond limit)
S – Statement Coverage
B – Branch Coverage
C – Condition Coverage
M – Multiple Condition Coverage
L – Loop Testing
P – Path Coverage
Conclusion
White Box Testing is an essential test case design approach for detecting hidden logical errors and
ensuring code completeness. It requires deep knowledge of the code structure and is usually
performed by developers or experienced testers.