API contract testing checks whether a consumer and provider agree on the messages exchanged at their boundary. Integration testing checks whether connected components work together in the integrated setup being tested. Use contract tests to verify compatibility; use integration or functional tests to verify behavior, data flow, and side effects. Many systems need both.
What is the difference?
| Question | API contract testing | Integration testing |
|---|---|---|
| What does it check? | Whether a specific consumer-provider interaction matches the expected request and response, or message. | Whether connected components work together in the tested setup. |
| Typical scope | A particular API or messaging boundary. | A component boundary, service path, or larger integrated system; scope varies by team and test. |
| What dependencies are involved? | Consumer and provider can be checked separately, with a mock provider for consumer tests and provider code for verification. | May involve real connected components or dependencies, depending on the scope. |
| What does a pass establish? | The tested messages match the recorded expectations. | The tested integrated behavior worked under the conditions exercised. |
| What can it miss? | Business correctness, persistence, and behavior not represented in the tested contract. | Paths and behaviors outside the test’s coverage. |
Pact describes itself as “a code-first tool for testing HTTP and message integrations using contract tests.” Pact documentation focuses those tests on the messages exchanged at an integration point. For HTTP, that means requests and responses; for queues, it means messages.
As an Amazon Associate I earn from qualifying purchases.
“Integration testing” is broader and does not have one fixed scope across teams. It can test whether a group of services is wired together correctly, whether data travels through a path, or whether a dependency works as expected. It is not automatically an end-to-end test: the components and behavior included depend on what the test is designed to cover. Pact’s testing-scope guidance also distinguishes focused contract coverage from wider integration coverage.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
What does a contract test prove—and not prove?
A contract test provides evidence about communication: the consumer’s tested interaction and the provider’s response or message conform to the shared expectations in the contract. It does not show that the provider performed the correct business operation. A response can match the contract even if an order was not saved, a calculation was wrong, or another side effect failed.
For that reason, Pact distinguishes contract tests from functional tests, which check provider behavior and side effects. Use broader functional or integration tests when correctness depends on business rules, real dependencies, persistence, or a complete data path. Pact’s explanation of contract tests versus functional tests covers this boundary.
How consumer-driven contract testing works in Pact
- The consumer defines an interaction. It records the request it needs to make and the response or message it expects from the provider. This makes the contract reflect a concrete consumer requirement. Pact’s consumer guidance describes the consumer’s role.
- The consumer test runs against a mock provider. The consumer can check its assumptions without requiring the real provider to be available.
- The test produces a Pact file. The file records the consumer, provider, and interactions that make up the contract.
- The provider verifies the contract. Verification replays the expected requests against provider code and checks whether its responses match the contract.
- Teams share and coordinate verification. A Pact Broker can share contract artifacts and support verification in a CI/CD workflow. Pact describes it as a service with an API and UI; the documentation cited here does not establish current pricing or partnership terms. Pact’s terminology guide explains the Broker and related terms.
This workflow lets consumer and provider teams check compatibility without deploying every participating application together. Pact also documents provider-only contract testing, but consumer-driven tests are useful when teams need the contract to capture what actual consumers require. Pact’s workflow overview explains the consumer and provider responsibilities.
How contract tests differ from schema or documentation checks
A documented API specification can be checked against a provider implementation to help keep the implementation and documentation aligned. That answers whether the provider conforms to the documented specification; by itself, it does not establish that consumers make the calls the provider supports or need. Consumer-driven contracts capture tested interactions from the consumer’s perspective, so they address that compatibility question more directly. Pact’s introduction discusses this distinction.
Recommended Free Tools
Likewise, generating a contract by hand from an API document does not demonstrate that a consumer actually uses those interactions. Pact’s FAQ explains why doing so defeats the consumer-driven purpose of the workflow. See Pact’s FAQ for that guidance.
When should you choose each kind of test?
Choose contract tests when compatibility is the main risk
- Multiple teams deploy services independently and need to know whether a provider change breaks a consumer’s expected request or response.
- API clients or message consumers depend on specific interactions that can be captured as executable examples.
- You want focused checks of the service boundary without requiring all participating applications to run together.
Choose integration or functional tests when behavior is the main risk
- You need to verify business rules or the result of an operation, not just its message shape.
- The behavior depends on actual dependencies, data movement, persistence, or side effects.
- You need evidence that a broader service path works in the integrated conditions represented by the test.
Use both when both risks matter
Contract tests can check whether services still speak the expected language; broader tests can check whether the connected system does the right thing with that communication. A passing contract test is evidence for the interaction it covers, not a substitute for behavioral coverage. Conversely, a passing integration test of selected paths does not automatically cover every consumer’s expected interaction.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.A practical way to interpret a passing test
- Contract test passes: the tested request and response or message matched the contract. It does not prove the business outcome or side effects.
- Integration test passes: the components and behavior included in that test worked together under its tested conditions. It does not establish that untested paths work.
Choose the test based on the claim you need evidence for. If the claim is “this consumer and provider still agree on these messages,” a contract test fits. If it is “this operation reaches the right dependency and produces the intended persisted result,” test the integrated behavior as well.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




