Technology RadarTechnology Radar

Pact

Trial

Pact is a software library available in multiple programming languages, designed to facilitate the creation and verification of contracts between consumers and providers. It implements the Consumer-driven Contract Testing (C.D.C.) approach by enabling consumers to define contracts through specific tests that outline the expected behaviors from providers.

Key features of Pact include:

  • Contract Creation: Consumers define contracts by writing tests that express expectations for provider interactions. These tests are scoped to the system's edge, which is directly responsible for interacting with the provider.
  • Pact File Generation: When executed, the tests produce a Pact File, a detailed artifact containing the recorded interactions and the expected states of the provider required to fulfill the contract.
  • Provider Validation: The Pact File is validated in the provider's CI pipeline against a transient instance configured to simulate the defined states and interactions. Provider-side tests focus solely on the public interface known to consumers.

For more information, check the Pact documentation and a running example of consumer and provider contract test definitions.