2 ms·
I've always been dubious of using mock for tests which involve external API calls; at best they require you to reimplement the API according to the documentatio
by askvictor 7y ago
I've always been dubious of using mock for tests which involve external API calls; at best they require you to reimplement the API according to the documentation (which there may be none, or that the API doesn't follow exactly for edge cases (i.e. the things you're meant to be testing)). At worst you're implementing a very small subset of the behaviour of the API and not testing how your code responds to the other behaviour. But I haven't come across other solutions (not that I have that a heap of experience here, just contributions to a couple of oss projects).
- alexanderdmitri 7y agoMocking inputs from APIs is actually great if someone besides the original developer picks up the codebase, whether from a system or even down to isolated function stubs. This is because it gives insight into the expected inputs the original developer(s) had been expecting and can elucidate the source under test. Integration tests fill the hole you're pointing out. You can even have integration tests designed to validate the mock inputs in many cases.