2 ms·
Mocking helps with architecture, though. When A calls C through B, you have a tight coupling between A and C, but mightn't be aware of that, because you only s
by berkes 5y ago
Mocking helps with architecture, though.
When A calls C through B, you have a tight coupling between A and C, but mightn't be aware of that, because you only see A calling B.
Lets say C reads a CSV file. By testing implementation only, you might 'create a csv file' then call A.import() and assert some records in, say D are created.
By testing A in isolation, you make apparent that it couples to C and D because you have to mock them out. B is a direct dependency of A, so you don't mock that. At the least, you have now documented the accidental coupling. But at the best, your tests showed you a design issue.