Skip to main content

White Box Testing

White box testing designs and executes tests with full visibility into the internal code, logic, and structure of the system under test — as opposed to black box testing, which only observes inputs and outputs. Developers writing unit tests are doing white box testing by definition.

Because the tester can see the actual code paths, white box testing techniques target structural coverage directly — branch coverage, statement coverage, path coverage — designing test cases specifically to exercise every conditional branch or logic path, not just every documented feature.

Its main cost is coupling: white box tests are tied closely to implementation details, so refactoring code (even without changing behavior) can break tests that were written against the old structure. Black box tests, by contrast, stay valid as long as the external behavior doesn't change.