5 ms·
Googler, opinions are my own. My corner of the world has ~100 people working on it and we do a mix of unit tests and integration tests. We definitely use mock
by kyrra 5y ago
Googler, opinions are my own.
My corner of the world has ~100 people working on it and we do a mix of unit tests and integration tests. We definitely use mocks, but prefer fakes where possible. I really like our unit tests to poke and prod the corners of a given small section of code.
Our integration tests are just that, and they serve their purpose as well. But being able to stress all underlying parts of the system with all possible inputs at the integration test level is really really hard (if not impossible).
Many times, the way a system currently is can't push the corners of some helper class deep down, and you won't find those until someone makes some change in an intermediary layer. Making sure things are working at both the micro and macro level seems like the best way to go. But there is the obvious tradeoff of time it takes to do this.
Other teams we work with are write only integration tests. While it mostly works, I would say that it's harder for someone else to come into the code base and make changes. Unit tests help people understand how the code is expected to work today and how their changes may impact that. Integration tests won't always catch those kinds of things (plus tend to be way longer to run, which makes iteration time longer).
- mikepurvis 5y agoYeah, I hear that. I wonder if there's a cart/horse issue here where the greatest value for low level unit tests is when you have a well-documented, thoughtfully architected system. Then the tests are verifying intentional behaviours and helping ensure the longevity of the system as designed. I don't think I have this experience first-hand, but I could certainly imagine a scenario where a well-intentioned person added a bunch of unit tests to a badly designed system, and they ultimately ended up just getting in the way and causing confusion when it was time to rethink it.