A conversation about how to, and when to mock came up today and I shared my thoughts with Headspring in our HipChat room. It was shared on Twitter by Sharon and my friend Ryan asked for the link to that list. It turns out there was no link, but I’m going to fix that now.
When do I feel like I should use a mock? Glad you asked!
By no means is this a complete list, but I try to keep things like this in mind when I’m testing my code. If there’s something more to the code than meets the eye, I consider a mock.
Also to note: I have tried my best (and have been doing a good job lately) of avoiding mocking frameworks. If I can get by with writing my own mocks occasionally, or just using real code, I’ll do that. I’ll pull in a mocking framework like NSubstitute if the pain is too much.
What are some other good reasons to mock your dependencies when you want to test?