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.

MediumTechnical
62 practiced

Write a parameterized test that checks an API's input validation by sending it several different invalid payloads and confirming each one produces the expected status code and error message. How would you structure the test data so the suite stays maintainable as more invalid cases are added?

EasyTechnical
57 practiced

Describe what a comprehensive testing approach for a REST API actually covers end to end: functional correctness, schema validation, error handling, authentication, and how contract testing fits alongside all of that. What tools would you reach for, and how does an exploratory pass differ from your automated suite?

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.

EasyTechnical
53 practiced

You're asserting that an API uses HTTP status codes correctly across the full 1xx-5xx range. How would you organize those assertions by range, and what's a realistic way a service could return the wrong status code while still looking superficially correct? Write a test that would catch that specific case. How should an automated test treat an asynchronous 202 response differently from an immediate 200 or 201?

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.

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.