When do you need to mock? In my experience, I need...
# test
r
When do you need to mock? In my experience, I need a mock when I’m interacting with some side-effectful code, for example, something that sends an email or makes a call to a billing system, etc. And I generally need to mock these interactions because I don’t want to actually send an email, or charge a credit card. For cases like this, even if there is only one implementation, I will always have an interface. The trade off is very little: writing a few lines of code for an interface vs not following some principles outlined by Goetz in his book, I’ll always pick writing interfaces.