- 2069 Chaitra · 5 marks
- Year not given · 5 marks
Black-box versus white-box testing
Short answer
The fundamental difference is that black-box testing derives tests from the specification without seeing code, while white-box testing uses internal code structure to exercise statements, branches, and paths. Black-box finds missing functions and interface errors; white-box finds logic errors and unreachable code. Both are complementary.
What is the fundamental difference between a black-box test and white-box test? Explain with appropriate examples of software test.
The fundamental difference is what the tester can see. In black-box testing the program is treated as a closed box: test cases are derived only from the specification (inputs and expected outputs), without looking at the code. In white-box testing (glass-box or structural testing) test cases are derived from the internal structure of the code, so that statements, branches and paths are exercised.
| Point | Black-box testing | White-box testing |
|---|---|---|
| Basis of tests | Requirements/specification | Source code and logic |
| Knowledge of code | Not needed | Required |
| Also called | Functional, behavioural testing | Structural, glass-box testing |
| Techniques | Equivalence partitioning, boundary value analysis, decision tables | Statement, branch, path coverage, basis path testing |
| Finds | Missing/incorrect functions, interface and performance errors | Logic errors, unreachable code, wrong conditions |
| Level | Mostly system and acceptance testing | Mostly unit testing |
| Done by | Independent testers, users | Developers |
Example of a black-box test
A form accepts age from 18 to 60. Without reading the code, the tester chooses equivalence classes and boundaries:
| Input | Class | Expected |
|---|---|---|
| 17 | below range | Rejected |
| 18 | lower boundary | Accepted |
| 35 | valid | Accepted |
| 60 | upper boundary | Accepted |
| 61 | above range | Rejected |
Example of a white-box test
int grade(int marks) {
if (marks >= 40)
return PASS;
else
return FAIL;
}
The tester reads the code and sees one decision, so cyclomatic complexity V(G) = 1 + 1 = 2. Two test cases give full branch coverage: marks = 40 (true branch, PASS) and marks = 39 (false branch, FAIL).
Black-box testing cannot show that every part of the code was executed, and white-box testing cannot show that a required function is missing. So both are used together.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Black-box testing · Software Engineering, chapter 8
- Alpha versus beta testing · Software Engineering, chapter 8
- Software testing metrics · Software Engineering, chapter 8
- Testing principles and testability · Software Engineering, chapter 8
- Functional versus structural testing; COCOMO for 200 KLOC · Software Engineering, chapter 8
- Real-time versus ordinary software and OS; data acquisition · Software Engineering, chapter 4
- White box and black box testing · Instrumentation II, chapter 9
- Software bugs and testing techniques · Instrumentation II, chapter 9 · asked 2×
- Software testing time paradox · Instrumentation II, chapter 9
- Hypothesis testing; difference of two proportions · Probability and Statistics, chapter 7 · asked 2×