TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Test Isolation Is About Avoiding Mocks

78 pointsby gary_bernhardtabout 11 years ago

4 comments

hibikirabout 11 years ago
Yes, we should avoid mocks of mocks. But building small pieces of code that have little knowledge of their surroundings, and testing them independently, is no panacea.<p>You can see this problem in any Java Enterprise shop that has code coverage as a religion: To make it possible to cover all that code (including all the boilerplate caused by the technologies selected), then we end up with a billion little classes that are managed by some kind of dependency injection system. Hundreds of thousands of lines of Spring XML configuration files, or their equivalent in annotations. Every piece is tested, but are all the pieces tested together, automatically? We quickly get into extremely large and expensive automation suites, or a whole lot of things that aren&#x27;t really tested regularly, making all those unit tests a lot less valuable.<p>We can&#x27;t wish complexity away: Make every unit too small, and the management of the units is now your new problem. You head in the same direction with the whole Microservices context.<p>A maintainable system is one built of components that are just simple and cohesive enough to be understandable by a human, but not any simpler. The right modularization is the hardest thing we do in software. The right size is hard to gauge, modules like that might be hard to name, and they are often hard to test. Sometimes one of those aspects must suffer for the others to do well.
评论 #7752234 未加载
评论 #7752582 未加载
henrik_wabout 11 years ago
Reducing the knowledge of internal structures is what the Law of Demeter (<a href="http://en.wikipedia.org/wiki/Law_of_Demeter" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Law_of_Demeter</a>) is about. Usually good practice.
评论 #7752118 未加载
adamorsabout 11 years ago
Well, one thing I learned from all this recent TDD related discussion is that almost nobody is aware of this book [1] and the entire school of TDD it spawned.<p>[1] <a href="http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Growing-Object-Oriented-Software-Guide...</a>
评论 #7751964 未加载
评论 #7751928 未加载
vinceguidryabout 11 years ago
I&#x27;m just happy Gary&#x27;s gracing us with his wisdom semi-regularly again.