Skip to main content

Describe how you would test an API that depends on a third-party service.

  • third-party APIs
  • mocking
  • service dependencies

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Layers of testing: (1) Unit tests with mocked third-party responses (fast, reliable). (2) Integration tests with a sandbox environment if the third-party provides one (Stripe test mode, Twilio test credentials). (3) Contract tests to verify your code handles the documented response shapes. (4) Synthetic monitoring in production to catch third-party outages. (5) Test error handling: timeouts, rate limits, malformed responses, partial outages. Never let your tests depend on a live third-party in CI.

What interviewers listen for

  • Schema-first thinking
    You validate response shape before you assert on values, every time.
  • Status-code literacy
    You can defend why 401 vs 403 vs 422 matters for the consumer.
  • Contract awareness
    You know when consumer-driven contract tests beat end-to-end checks.
  • Auth fluency
    You can describe rotating tokens across parallel workers without secrets in logs.

See all 35 api testing questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026