Middle+
What is contract testing and what does it verify?
sobes.tech AI
Answer from AI
Contract testing is a testing method that verifies the interaction between two systems or components, such as between a provider service and a consumer service. The main goal is to ensure that both parties agree on the format and content of the data they exchange.
What contract testing checks:
- Matching API specifications between the consumer and the provider.
- Correctness of requests and responses (structure, data types, required fields).
- No regressions in interfaces when changes are made.
Example: if the frontend expects the API to return an object with id and name fields, contract testing will verify that the backend indeed returns these fields in the correct format.
This helps avoid integration issues and speeds up development, allowing teams to work independently based on an agreed contract.