Behavior Testing vs. Implementation Testing¶
Tests coupled to observable behavior (outputs, side effects) remain valid through refactoring; tests coupled to implementation details (internal method calls, data structures) break during legitimate refactoring and must be rewritten.
Tension Addressed¶
Sensitivity vs. Stability
Recognizable As¶
Tests asserting on return values vs. asserting on method call sequences; tests that survive refactoring vs. tests that break on internal changes; "black box" vs. "white box" testing discussions
Canonical Sources¶
Beck, "Test-Driven Development" (2002); Fowler, "Refactoring" (1999); Freeman & Pryce, "Growing Object-Oriented Software, Guided by Tests" (2009)
Transfers To¶
API versioning (stable interfaces, changing implementations); information hiding in design; encapsulation principles
Kent Beck's principle captures this: tests should be sensitive to behavior changes (catch real bugs) and insensitive to structure changes (survive refactoring). Tests that verify implementation details become maintenance burdens that resist improvement.
Related Concepts¶
- Encapsulation - Software Architecture
- Information Hiding - Software Design