Skip to main content

What is contract testing and how does it differ from integration testing?

  • contract testing
  • pact
  • microservices

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

Model answer

Contract testing verifies that a provider API meets the expectations defined by consumer services, without deploying both together. Tools: Pact, Spring Cloud Contract. Integration testing deploys both services and tests actual communication. Contract testing is faster, runs in isolation, and catches breaking changes early. Use contract testing when: many consumers depend on an API, teams deploy independently, or integration environments are costly. The contract is a shared agreement, not a full integration test.

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.

Terms to know

See all 35 api testing questions

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