API Testing · Senior · Question 30 of 75
How can mocks of a dependency drift from reality, and how do you catch it?
- 1Mocks change by themselves; reset them before every test run
- 2Mocks never drift as long as nobody edits the mock files
- 3The real API changes; verify mocks via contracts or scheduled runs
Show the answer
Correct answer: The real API changes; verify mocks via contracts or scheduled runs
Explanation
A stub saying 200 while the real service now returns 201 hides integration bugs. Contract tests or scheduled checks against the real API keep stubs honest.