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

  1. The consumer defines its expectations in a 'contract'.
  2. The provider is tested to ensure it can fulfill those expectations.
  3. 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.

Related Terms