API Testing · Middle · Question 67 of 75
How do you test API behaviour when a downstream service returns invalid JSON?
- 1Stub the dependency with broken JSON and check the error handling
- 2It can't happen, since services always return valid JSON
- 3Wait until the downstream service breaks in staging
Show the answer
Correct answer: Stub the dependency with broken JSON and check the error handling
Explanation
The API should return a clear 502 or fallback, log the problem and not crash or return garbage.