Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


This 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.


> 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.


100%. Its called efferent coupling.


It's answer which is technically 100% right; and practically 100% missing the point. So it seemed facetious.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: