Introduction: Test Doubles—Stubs and Mocks

Get yourself introduced to what we will learn in this section.

We'll cover the following

In this section, we’re going to solve a common testing challenge.

How do you test an object that depends on another object? What do we do if that collaborator is difficult to set up with test data?

Several techniques are available to help us with this and they build on the SOLID principles we learned previously. We can use the idea of dependency injection to enable us to replace collaborating objects with ones specially written to help us write our test.

Get hands-on with 1200+ tech skills courses.