3 ms·
Assume that when you have N consumers of an interface then your coupling is N. Mocks consume an interface as does your codebase so your coupling is at least N=2
by pling 12y ago
Assume that when you have N consumers of an interface then your coupling is N. Mocks consume an interface as does your codebase so your coupling is at least N=2 whereas your codebase alone was N=1. By using mocks, programmers cause coupling to increase so programmers should stop using mocks to decrease coupling.
- SideburnsOfDoom 12y ago> Mocks consume an interface as does your codebase so your coupling is at least N=2 whereas your codebase alone was N=1. I really hope that you're not being serious here.
- pling 12y ago100%. Its called efferent coupling.
- SideburnsOfDoom 12y agoIt's answer which is technically 100% right; and practically 100% missing the point. So it seemed facetious.
- the_af 12y agoThis is technically true but I don't think it's a good argument against mocking or test doubles. By this reasoning, the test suite itself causes coupling to increase. For any component C, you have at least N=2: when it's used in production code, and when it's tested. If you don't test C, you reduce N to 1. This doesn't sound like a good argument against testing, though.