InterviewStack.io LogoInterviewStack.io

API and Contract Testing Questions

Testing services and their interfaces directly. Covers REST and other API testing, request/response and schema validation, status and error handling, and contract testing between producers and consumers. Includes service-level and integration testing without a UI.

EasyTechnical
101 practiced

Explain consumer-driven contract testing: what problem it solves, how it prevents integration regressions between a service and its consumers, and what the consumer and provider sides are each responsible for in CI. What tooling typically supports it, and what pitfalls do teams commonly run into when adopting it?

MediumTechnical
74 practiced

You consume webhooks from an external vendor that signs each payload with HMAC SHA-256 and includes a timestamp to guard against replay. Write a Postman pre-request script (or describe the equivalent code) that generates the correct signature header for a test webhook request, and describe the automated tests you'd write on the receiver side to verify signature validation, timestamp freshness, and replay protection.

EasyTechnical
68 practiced

What does a solid test-data strategy for API and service tests actually look like in practice? Cover how you'd decide between generating data on the fly versus using fixed fixtures, when synthetic data is good enough versus when you need something closer to real production data, and how you keep tests from interfering with each other's data.

MediumTechnical
63 practiced

Implement a reusable function that performs an HTTP GET with retry and exponential backoff for transient failures (server errors and network errors), with configurable attempt count and base delay. What do you need to be careful about if this function is used concurrently by many tests at once?

MediumTechnical
70 practiced

Write a pytest suite for a GET-by-id endpoint. It should include a fixture that creates the test data it needs, parametrized cases covering both an existing and a non-existing ID, and teardown that removes what it created. What would you actually assert on the response beyond the status code?

Unlock Full Question Bank

Get access to all 44 API and Contract Testing interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.