Contract testing checks an integration point by testing each application in isolation against a shared contract that records the messages one side sends and the other expects. The caller is the consumer and the responder is the provider. It catches a breaking API change without deploying both services, but it does not prove the whole flow works.
How does contract testing compare with integration testing?
Both check that two services work together. They differ in what has to be running and what a failure tells you.
| Integration test | Contract test | |
|---|---|---|
| What runs | Both services, often with a database and other dependencies | One service at a time, against a recorded contract |
| What it proves | The real chain works in that environment | Each side keeps its part of the agreed messages |
| Where a failure points | Somewhere in the chain, often after deployment | At the request and response that no longer match the contract |
| Environment needed | A shared test environment | The developer’s machine or the CI job |
| Weak spot | Expensive and brittle, in Pact’s words | Anything nobody wrote into the contract, and the whole flow |
The Pact documentation argues that without contract testing, the only way to know applications work together is expensive and brittle integration tests. That is the project’s view of its own technique. A contract test does not check the whole flow, so add contract tests next to a small set of integration tests instead of removing those. Our integration testing services page covers the chain-level checks.
What are consumer-driven and provider-driven contracts?
A contract sits between a consumer, the application that makes a request, and a provider, the application that answers. Two styles exist.
In the consumer-driven style, the consumer’s own tests produce the contract. The Pact JS documentation says the consumer writes a test that sets out its assumptions and needs, and the library writes the interactions to a contract file. The provider replays them to confirm it can meet them. Pact’s introduction notes that only the parts of the communication the consumers use get tested, so provider behavior no consumer uses is free to change without breaking tests.
In the provider-driven style, the provider’s documentation is the contract. The OpenAPI Specification defines a standard, language-agnostic description of HTTP APIs, and tests check the provider against that document. The Pact introduction points out that this on its own gives no test-based assurance that consumers call the provider correctly. Names vary between tools: Pact calls this provider contract testing, and the Spring Cloud Contract documentation says it lets you perform “consumer-driven and producer-driven contract testing”.
A schema describes every possible state of a resource. A Pact contract, in Pact’s own words, is “contract by example”: each test case describes one concrete request and response.
When is contract testing worth it, and when is it not?
It is worth it when several teams own services that call each other and a change by one team can break another without anyone noticing until a shared environment goes red. That is typical of microservices, and of a web or mobile client calling an API that another team deploys. The Pact JS overview lists the benefits the project claims, among them local tests, faster deploys and less reliance on complex test environments. Treat those as the tool’s claims, not a measurement of your system.
Our rule of thumb: skip it when a single team owns both sides and deploys them together, because a normal integration test covers the same risk with less setup. We would also expect little from it if the API changes rarely, or if nobody will maintain the contract files and the process that shares them between teams.
If you are weighing it against broader API checks, see our guide to API test automation.
What mistakes do teams make with contract testing?
- Treating it as a replacement for integration tests. A contract says nothing about the whole flow. Keep a small set of end-to-end checks on the paths that carry revenue.
- Writing contracts by hand to match the whole API. In the consumer-driven style, the contract should record what the consumer uses. A contract copied from the full response makes harmless provider changes look breaking.
- Verifying against a stale contract. The provider has to verify the latest contracts from every consumer in CI, otherwise the check passes while the real client has moved on.
- Skipping the ownership question. When a contract test fails, someone has to decide whether the consumer or the provider changes. Agree who decides before the first failure.
- Mixing up two meanings of the term. Pact notes that “contract testing” is sometimes used for checking a provider against its own documentation, such as an OpenAPI file. That is useful, but it is a different check from testing the consumer and the provider against the same contract.
For the distributed-systems problems contract testing addresses, and a consumer-driven workflow demo, see Bas Dijkstra’s recorded talk Improving your integration testing efforts with contract testing.
What does Zapple.Tech do about it?
If you are not sure whether your services need contract tests, integration tests or neither, start with the evidence. Zapple.Tech starts with a one-week QA audit of one product area. It looks at its tests, pipeline and release process, and ends in a written report on what is at risk and what to fix first, plus a pilot plan you can run with Zapple.Tech or without it. Read more on the QA audit and assessment page.
When the plan includes API-level checks, API and server-side test automation covers building them. Tell us about your services in the form below. More terms are in the QA glossary.
How does contract testing relate to other terms?
- API testing
API testing checks a service directly through its interface rather than through a screen. Tests send requests to endpoints and verify responses, business rules, data and access rules. Our API testing services write automated API tests in your repository, covering contracts and back-end rules, and run them in your CI on every change.
- Integration testing
Integration testing checks the interfaces and interactions between components, or between your system and other systems and external services. It finds faults in the data they exchange and the flows that cross them. Our integration testing services write automated tests for your services, databases and third-party systems, and run them in your CI.
- Service virtualization
Service virtualization replaces a system your tests depend on, such as a payment provider or a service another team has not built yet, with a simulated version that answers like the real one. It lets you test when the dependency is slow, costly or missing. It pays off only if someone keeps the simulation in step with the real service.
- Test pyramid
The test pyramid is a model for spreading automated tests across levels: many fast unit tests at the base, fewer service tests in the middle, and few slow end-to-end tests through the user interface at the top. Mike Cohn described it as the test automation pyramid. It guides proportions, not exact ratios: tests higher up are slower and cost more.
Sources
- Pact documentation, Introduction (updated 2026-12-02) (read 5 December 2026)
- Pact JS documentation, Overview (updated 2026-07-22) (read 6 December 2026)
- Pact JS documentation, Consumer tests (updated 2026-07-22) (read 5 December 2026)
- OpenAPI Specification v3.2.1 (published 2026-09-10) (read 5 December 2026)
- Spring Cloud Contract reference documentation (stable 5.0.3) (read 5 December 2026)