DEV Community

Discussion on: To mock, or not to mock, that is the question

Collapse
 
kondrashov profile image
Alex Kondrashov

Great point about the test pyramid, Anthony.

We should be having more unit tests than integration tests as per the test pyramid. Yet often times I see that tests scew towards the unit testing + mocking. Hence this article is a reminder that we also can write other types of tests to better balance the pyramid.

Collapse
 
ant_f_dev profile image
Anthony Fung

Yes - good point about the distribution of test types.

I suspect that the prevalence TDD has something to do with that. I'm not saying TDD is either good, or bad - I'm just saying that it encourages writing unit tests and then filling in the implementation.

With so many jobs on the market that want TDD as a requirement, my guess is that many people learn to do TDD with unit tests and don't think much about the other possibilities.

Thread Thread
 
kondrashov profile image
Alex Kondrashov

I agree, TDD is having an effect on this. Although I've done TDD in the past where I wrote couple integration tests which was convinient.

Thread Thread
 
ant_f_dev profile image
Anthony Fung

It's definitely worth testing a chain of components when it's the easiest way.