Chapter 13. Mocking Frameworks

Today the number of cases in which we want to implement test doubles by hand is quite limited. Mocking frameworks have been evolving for several years and have reached full maturity by now. At the time of writing, they’ve gone through generations of evolution and have reached a point where they offer very rich functionality and truly simplify many aspects of interaction testing. A case in point is the fact that mocking frameworks, despite their names, not only construct mock objects, but also stubs and spies.1 My experience is that this versatility often leads to confusing tests, where the role of the test double is ambiguous and unclear. That’s why I emphasize the type of test double wherever possible. To avoid ...

Get Developer Testing: Building Quality into Software 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.