Answer: Black box testing checks what the software does (its functions) without looking at the code, while white box testing checks how it does it by testing the internal code structure, paths and logic.
| Basis | Black box testing | White box testing |
|---|---|---|
| Meaning | Tests the software from outside using inputs and expected outputs; internal code is unknown to the tester. | Tests the internal structure, code and logic; the tester knows the code. |
| Other names | Functional, behavioural, closed-box testing | Structural, glass-box, clear-box, open-box testing |
| Based on | Requirements / SRS | Detailed design and source code |
| Programming knowledge | Not needed | Required |
| Done by | Mainly independent testers and end users | Mainly developers |
| Testing levels | System and acceptance testing (higher levels) | Unit and integration testing (lower levels) |
| Techniques | Equivalence partitioning, boundary value analysis, decision tables, cause-effect graphing, state transition, error guessing | Statement coverage, branch/decision coverage, condition coverage, basis path testing (cyclomatic complexity), loop testing, data flow testing |
| Finds | Missing or wrong functions, interface errors, behaviour and performance errors | Logical errors, unreachable code, wrong loops and conditions, unused variables |
| Time and cost | Less time-consuming | More time-consuming and detailed |
| Test case design start | Can start as soon as requirements are ready | Starts after the design/code is available |
| Suitable for algorithm testing | No | Yes |
| Example | For a login page, enter valid and invalid username/password combinations and check the messages. | For a function with an if-else and a loop, write cases so every branch and the loop (0, 1, many times) is executed. |
Note: Grey box testing combines both: the tester has partial knowledge of the internals while testing from outside.