Testing interview question
What is contract testing, and when would you use it?
Definition Asked in Backend Engineer · QA Engineer / SDET · Frontend Engineer · Full Stack Engineer interviews
Summary
Contract testing checks that a service and its consumers agree on the API between them, without running both together. In consumer-driven contract testing (Pact), each consumer records the requests it makes and the responses it expects; the provider verifies it satisfies every contract in its own CI. It catches breaking API changes early in microservice systems.
Keep reading with a membership
The full answer with examples, key points and comparisons is part of the membership, along with every other interview answer, progress tracking and Daily Review. Most-asked answers stay free to read.
More Testing questions
- What makes a good unit test?
- How do you write reliable integration tests that use a database?
- What is the test pyramid, and is it still relevant?
- How would you design a test strategy for a new web application?
- Write a Playwright test that logs in and checks the dashboard, and explain how you keep it stable.
- What's the difference between mocks, stubs, fakes and spies?
- Your end-to-end test suite is flaky and takes an hour. How do you fix it?
- What causes flaky tests and how do you fix them?