DEV Community

Discussion on: Try ending today with a failing test for a great start tomorrow

 
nholden profile image
Nick Holden

I generally try to avoid mocking whenever possible.

When I'm testing requests to external services in Ruby, I'll use VCR and WebMock so that my test suite doesn't need to make HTTP requests, and when I'm testing how an application handles webhook events, I'll write fixtures to fake the payloads of incoming requests. Very occasionally I'll reach for the mocking built into RSpec for other purposes.

But for the most part, I tend to avoid mocking.

Thread Thread
 
hilaberger92 profile image
Hila Berger

Why do you tend to avoid mocking?

Thread Thread
 
nholden profile image
Nick Holden

When it's feasible, testing the real system rather than mocks gives me more confidence that the thing I'm testing actually works.

Thread Thread
 
hilaberger92 profile image
Hila Berger

I understand what you mean, but mocks can help you test more cases, thus you can be confident that the thing you're testing works on edge cases too, don't you think?