What is white-box testing?
White-box testing designs tests using knowledge of the internal code, paths and logic.
Testers or developers read the code and write tests to exercise specific branches, conditions and paths. Unit tests and code-coverage-driven testing are typical examples.
It is effective for thorough logic testing but can couple tests tightly to implementation details, making refactoring harder.
Example
A developer sees a function has a special branch for leap years and writes a test for 29 February to make sure that branch is exercised.
Best practices
- Target complex branches and conditions
- Use coverage tools to find untested paths
- Avoid asserting on private implementation details
Ship without fear.
Start testing free in minutes, or let a QAShift engineer deliver your first morning report within 5 days.