Dummy and Mock Objects for Independence
In an averagely complex application, an object can hardly do without the cooperation of many other objects of the same or another class. So how can we test an object that depends on so many others? The most pragmatic and (probably) intuitive way out of this dilemma is the bottom-up approach: we begin our development and testing with the classes that build themselves on system-owned classes. Then we use these tested components to build independent classes.
This approach is called bottom-up because we start from the very bottom, with the most concrete objects, working our way up to the more abstract components. We saw in Chapter 3, Section 3.2 that working top-down (or outside-in) is easier in ...
Get Unit Testing in Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.