Contract Testing

Contract tests verify that an API provider continues to satisfy expectations of its consumers.

This is particularly valuable in microservice architectures where independent teams deploy services at different times.

OpenAPI schemas can also be used to validate requests and responses automatically. Consumer-driven contracts can verify that the provider implements exactly what known consumers depend upon.

Key Takeaways
  • Test negative cases as aggressively as success cases.
  • Contract tests protect independently deployed systems.
  • Schema validation can catch accidental API changes.