liveBook · Manning

White-box testing

As explained in Unit Testing Principles, Practices, and Patterns

A software testing method that verifies internal implementation behavior using knowledge of the application's source code or structure.

White-box testing verifies an application's inner workings by deriving tests from its source code rather than from requirements or specifications. section 4.5

Use the approach with a clear view of its trade-offs:

  • It can uncover errors that external specifications may miss, improving protection against regressions. section 4.5
  • It often couples tests tightly to implementation, making them brittle and less resistant to refactoring. section 4.5
  • Prefer black-box testing for tests, and use white-box analysis to inspect their quality and coverage of important behavior. section 4.6
Table 4.1. The pros and cons of white-box and black-box testing (view table figure)
 

Protection against regressions

Resistance to refactoring

White-box testing Good Bad
Black-box testing Bad Good

Compare white-box and black-box testing across regression protection and resistance to refactoring. section 4.5

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Contrasts definitions, benefits, and brittleness but stops short of prescribing detailed test construction.
Examples
Compares tests derived from source code with tests derived from requirements and specifications.
What you can do after
Evaluate tests by balancing regression protection against brittleness and resistance to refactoring.
How it connects
Contrasts black-box testing and connects with the Test Pyramid, unit testing, regression protection, and refactoring.

Also explained in

Compare how 3 books explain white-box testing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.