3 ms·
most of the bugs are in the joints of the system, not in the components it's much easier to write modules that are internally consistent, much harder to be glo
by rictic 5y ago
most of the bugs are in the joints of the system, not in the components
it's much easier to write modules that are internally consistent, much harder to be globally consistent across modules. mocks ensure you only test for internal consistency
- barrkel 5y agoMocks don't test the joints, which you have just suggested are where the bugs are. Fakes get you a lot further without needing more comprehensive integration testing. Fakes simulate dependencies - so you can test the joints - but can be tested themselves, and most importantly can have conformance tests that validate that the fake acts like what it is faking.
- smaudet 5y agoFakes also make integration testing easier too - if you want to focus on say, making sure your payments always make it into the database correctly, integration testing across the medley becomes (relatively) trivial, even automatable.
- dustymcp 5y agoI could mock all day but it would not be any help since the api's we use are brittle its much more efficient to fail in a graceful way where you can recover than plastering the codebase with mocks of happy paths
- rictic 5y agosince both comments in response read it the same way, I suppose I was unclear I was arguing against mocks, and for only using fakes when you really have to, for hermeticity and performance
- delusional 5y agoWouldn't the integration (or global consistency as you call it) of objects be exactly what was worth testing in that's the hard part? Generally objects are simple enough that I can reason about them in my head. That's the whole point of encapsulating the state after all. That means tests are really less critical, since a thorough inspection should do. Between components it's MUCH harder to get any sort of coverage in your internal model, so tests that can be repeated become more useful. I want the tests to fail if the software doesn't work. Not if some object doesn't do what it says it will in a way that doesn't matter to the system. The hard part is exactly what I want tests to cover.