What is API contract testing, and how is it different from running a full integration test between two services?

technical-conceptual · Junior level · software-engineering

What the interviewer is really asking

Checks whether the candidate understands that a contract test verifies the agreed request/response shape between a consumer and provider in isolation, rather than spinning up both live services end to end.

What to say

What to avoid

Example answers

Strong: A contract test pins the shape of the agreement between a consumer and a provider: the consumer declares it expects a 200 with an `id` and `email` field, and that expectation is verified against the provider in isolation. An integration test would instead call the real running provider over the network, which is slower and breaks for reasons unrelated to the contract, like a flaky database.

Weak: Contract testing is basically integration testing; you run both services and check the API returns what you expect.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.