Hacker News new | ask | show | jobs
by deckar01 3763 days ago
Ideally foo and bar would be spies/mocks in that unit test, which means that X is 100% covered.

The advantage of unit testing modular code bases is that you don't have to test every program state, you just have to test every module state.

There is a huge difference in the feasibility of 100% code coverage if you need O(2^n) vs O(n) tests.

Even if your modules are highly coupled you should be able to mock away external dependencies and side-effects.

1 comments

"The advantage of unit testing modular code bases is that you don't have to test every program state, you just have to test every module state."

I don't think that's true with a capital T. Modules interact with each other. You can modularize, microize, or nanoize your application but the minimum subset of test-worthy states stays the same.