4 ms·
> I also dispute that it’s hard to unit test the first function—-you would simply mock the api response and then you have a great test. How many times have you
by acdha 6y ago
> I also dispute that it’s hard to unit test the first function—-you would simply mock the api response and then you have a great test.
How many times have you seen a test pass or fail when it shouldn’t have because the mocks didn’t match the actual code? It’s a useful technique but it has drawbacks which are not easily prevented.
- yeswecatan 6y agoYou would still need to use mocking to test the imperative shell
- danuker 6y agoThis, here, is what I meant!
- jakeva 6y agoWe use mocks a lot on my team, and I don't think we've ever seen what you describe. Maybe you're using mocks incorrectly?
- acdha 6y agoYou might also want to consider the possibilities that you have problems but haven't noticed them yet or that your experience is not a global truth applicable to all projects. If you think about the problem more, ask yourself how it's possible to mock a remote HTTP call without the risk of this problem? I've seen people write frameworks which periodically save and cache responses but unless you regularly perform some kind of validation there's no way to avoid that problem.