Author :
Freeman, Steve ; Pryce, Nat ; Kerievsky, Joshua
Abstract :
Test-driven development with mock objects is a technique to support writing truly object-oriented code. What matters in object-oriented programming is what objects do, how each object responds to and affects its environment. Everything else is internal. In our experience, TDD with mock objects, or interaction testing, helps us write flexible, well-structured code composed of objects that are easy to combine because they know as little as possible of the rest of the system\´s structure and state. It guides us toward focused objects with explicit dependencies, encouraging a "tell, don\´t ask" programming style that helps encapsulation by passing behavior to state rather than the reverse. The technique focuses the design effort on how objects communicate with each other rather than data storage or static classification hierarchies. Routinely test-driving code with mock objects leads to premature object composition, hard-to-read and fragile code, and lost time
Keywords :
data encapsulation; object-oriented programming; program testing; software engineering; data encapsulation; interaction testing; mock object composition; object-oriented code writing; object-oriented programming; test-driven development; Collaboration; Computer industry; Logic design; Logic programming; Logic testing; Network address translation; Object oriented programming; Programming profession; Software design; Software testing; mock objects; object-oriented programming; program testing; test-driven development;