Black-box testing

Black-box tests are tests that run without knowing anything about the internal structure of the software. They test what the software is expected to do from a business perspective.

White-box tests are the opposite of that. They test with a good understanding of the internal workings of the software.

Khorikov argues that since black box tests provide the best resistance to refactoring one of the 4 Pillars of Good Unit Tests, you should aim to mostly write tests in this style. Reserving white box testing for the analysis of your tests, for example, by utilising Test Coverage Metrics to examine branch or code coverage.

Khorikov (2020) (pg. 90)


Vladimir Khorikov. Unit Testing: Principles, Practices, and Patterns. Manning, Shelter Island, NY, 2020. ISBN 978-1-61729-627-7.