Definition. Black-box and white-box testing

[comp1110-3Z]

When writing tests we can take two perspectives on the code under test:

  • In black-box testing, tests are written against the interface (or specification) only, without looking at the implementation. This is the preferred approach for unit-testing interfaces, because the tests remain valid across all implementations.
  • In white-box testing, tests are written with knowledge of the implementation internals, targeting specific branches, edge cases, or internal states.
bars magnifying-glass caret-down plus minus arrow-right xmark