DEV Community

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

Collapse
 
nholden profile image
Nick Holden

Thanks!

It can definitely be tempting to tie up all loose ends at the end of the day. I've found that shutting down my laptop and cleaning up my workspace right after I've written the failing test can help me move on.

I do use TDD pretty regularly, and this idea has fit well within the red-green-refactor cycle for me.

Collapse
 
hilaberger92 profile image
Hila Berger

I'll try that :)
Which languages do you work with? do you use any unit testing/mocking frameworks?

Thread Thread
 
nholden profile image
Nick Holden

I work mostly with Ruby and JavaScript. I use RSpec for most of my Ruby testing, including unit tests. I haven't done much unit testing in JavaScript, but I'll test interactions with JavaScript in the browser using Capybara and ChromeDriver.

Thread Thread
 
hilaberger92 profile image
Hila Berger

Sounds interesting :)
Any suggestions for mocking frameworks for the server side?

Thread Thread
 
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?