Chapter 11Effective Mocking

images/mocking/intro2.png

Mocking is an effective tool for unit testing code, but it can be overused. Too many of the wrong kinds of mocks can make your tests brittle and hard to maintain. But the right kind of mocks can give you confidence while simultaneously enabling you to change your designs.

In this chapter we are going to look at the pros and cons that come with this style of unit testing, and see how you can use mocks effectively. By the end of the chapter you’ll not only know where the perils of mocking lie, you’ll know how to avoid them and make mocks work for you in your code.

Developers, this chapter is on unit testing and is directly ...

Get The Way of the Web Tester 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.