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
52 practiced

Your team has an SLA that a given API endpoint should respond within a set time for the large majority of requests. How would you write an automated test that checks this without it becoming flaky in CI? Think about what tolerance you'd allow and whether a violation should fail the build outright or just raise a warning.

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?

MediumSystem Design
64 practiced

You're serving a machine learning model behind an HTTP API that accepts a JSON feature payload and returns a probability distribution with some metadata. Design contract and schema tests for it: what would the schema need to specify, and how would you test that the API stays backward compatible and fails gracefully when an optional field is missing?

MediumTechnical
70 practiced

Write Postman test scripts (using pm.test and pm.expect) that check three things: a login request returns a token with HTTP 200, creating a resource returns HTTP 201 with the expected fields, and an unauthorized request returns HTTP 401. Also explain how you'd handle the token as an environment variable between requests.

EasyTechnical
59 practiced

You have a Postman collection that represents your team's API test suite. Describe, step by step, how you would run that collection automatically in CI: handling environment variables and secrets, deciding what should fail the build, and producing a report a dashboard could consume.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.