- Does a contract test replace an integration test?
No. Contract tests verify interface shape and semantics between two services in isolation. Integration tests verify end-to-end behaviour across a live environment. Contract tests reduce the number of integration tests you need, but a small end-to-end suite still catches failures that span three or more services.
- Who writes the contract?
The consumer writes it. The consumer knows which fields, status codes, and error shapes it actually depends on. The provider verifies it. If the provider wrote the contract, it would encode the provider's view of the world, which is exactly what the consumer is trying to protect against.
- What happens when the contract changes?
The consumer updates its expectations, publishes a new contract version, and the provider's pipeline verifies against the new version. Old contract versions can stay valid until the consumer stops depending on them. Versioning is what makes this a coordination tool rather than a synchronisation ritual.
- Do I need a service registry to do contract testing?
Not strictly, but at scale you do. Without a registry, contracts are files moved by hand between repositories. That works for two services. It breaks for twenty. A registry stores contracts with versions and lets providers pull the ones they need.
- Is contract testing worth it for a monolith?
Usually not. Contracts solve coordination between independently deployed services. In a monolith, all code ships together, so there is no drift to catch. The pattern earns its cost when teams deploy independently.