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.
Write Powerful Rust MacrosWhite-box testing evaluates software with knowledge of and access to its internal implementation, including private code paths.
black-box testingcontrasts with · Black-box testing evaluates software through externally observable behavior and interfaces without relying on knowledge of its internal implementation.
functional requirementmeasures · A functional requirement specifies a behavior or capability that a system must provide or enable.
testkind of · A test is a procedure or check that evaluates behavior using specified inputs or evidence against expected results or criteria.
endpointcontrasts with · An endpoint is a network-accessible address or interface through which a service exposes a resource or operation and handles requests and responses.
testabilityused by · Testability is the degree to which a system’s behavior can be exercised and evaluated effectively, efficiently, and reliably through testing.
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.