3 ms·
I don't necessarily agree that testability is the same thing as modularity. In my experience, tests that focus on one module in isolation and try to fake/mock a
by assbuttbuttass 2y ago
I don't necessarily agree that testability is the same thing as modularity. In my experience, tests that focus on one module in isolation and try to fake/mock all dependencies, including other modules in the same system, tend to be rather unrealistic and not that useful. Bugs are far more often found in the interaction between modules, due to mismatched assumptions between them. For this reason I try to fake/mock as little as possible in tests, and try to follow the principle "tests should run as close to prod as possible."
- tfandango 2y agoI feel the same. I work on a huge meandering system and most of the issues we encounter are caused by the interactions between modules, as you say. I've taken to writing and running "end to end" tests which test the whole process end to end and verify the outputs. Wherever it makes sense to add unit tests for specific contained logic, we do that too.
- o_nate 2y agoI think the author meant something different than how you read it. It sounds like you might agree. He is saying that if you have to mock a lot of dependencies then that is a red flag. Code that is easy to test (without writing a ton of mocks) will also be modular.