Overview
Contract testing ensures that a 'provider' (e.g., an API) and a 'consumer' (e.g., a mobile app) can communicate correctly. It focuses on the messages exchanged rather than the internal logic of the services.
How it Works
- The consumer defines its expectations in a 'contract'.
- The provider is tested to ensure it can fulfill those expectations.
- If the provider changes in a way that breaks the contract, the test fails.
Benefits
- Catches integration bugs early without needing a full staging environment.
- Enables independent deployment of services.