Recommended Free Tools
A passing API mock test proves that your client works with the response your test configured—not that the live provider still sends that response. To catch compatibility breaks, verify the consumer’s real request-and-response expectations against the provider, using consumer-driven contract testing such as Pact. If you need to check a broader documented API surface, add validation against its OpenAPI schemas; that answers a different question.
Why mock tests pass after an API change
A mock stands in for the provider. It returns the behavior encoded in the test, so the consumer can be tested quickly and repeatably without calling a live service. But that isolation has a limit: unless another check reaches the provider implementation or validates it against a shared contract or specification, a mock-only test does not establish that the current API still meets the consumer’s assumptions. Pact’s introduction to contract testing explains the difference between these consumer expectations and provider behavior.
As an Amazon Associate I earn from qualifying purchases.
For example, a client test may configure a mock to return a particular field and then confirm that the client displays it. If the provider later renames or removes that field, the test can still pass: the mock has not changed. The mismatch becomes visible only when the provider is checked against the interaction the consumer depends on.
Three testing approaches, three different checks
| Approach | What it checks | Useful when | What it does not establish |
|---|---|---|---|
| Mock-based test alone | Consumer behavior for configured mock interactions. | You want fast feedback on client logic and response handling. | That the current provider meets the assumptions encoded in the mock. |
| Consumer-driven contract with provider verification | Concrete request-and-response interactions that consumers rely on, replayed against the provider implementation. | Consumer and provider teams need a compatibility check across changes. | That the provider behaves correctly for every request or fulfills all functional requirements. |
| OpenAPI/schema validation | Provider requests and responses against schemas in a documented API description. | The API description is maintained and conformance to its broader documented surface matters. | Every consumer-specific expectation or semantic behavior not captured by the schema. |
Pact distinguishes consumer-driven contracts—concrete interactions used by consumers—from contracts based on a documented description such as OpenAPI. Its introduction describes the consumer-driven approach; MockServer’s contract-testing guide describes generating representative requests from OpenAPI and validating responses against defined schemas.
#1 Best Overall
How consumer-driven contract testing closes the gap
Consumer-driven contract testing records what a consumer actually needs from the provider, then checks that the provider still satisfies those expectations. Pact’s documented HTTP workflow separates this into consumer and provider work. The consumer test runs against a mock and records request-and-response interactions in a JSON contract. That contract is shared with the provider side, where the requests are replayed against a locally running provider implementation. Pact’s JavaScript consumer guide documents this workflow.
The important change is that the mock interactions no longer stop at the consumer test. They become inputs to a provider verification step. If a provider change breaks an interaction in the contract, verification can reveal the incompatibility before the affected change is released.
Capture only the behavior consumers rely on
Start with the client’s actual dependencies: the method and path, relevant request details, response fields it reads, and behavior it relies on. Add interactions that would catch meaningful breaking changes, rather than trying to encode every detail the provider could return. Pact’s consumer test guidance recommends examples that catch real breakages and are as loose as possible while still protecting compatibility.
This focus is useful when an API has more possible states or features than its current consumers use. A consumer contract protects the interactions those consumers recorded; provider behavior outside those interactions can change without breaking those contracts. That makes the contract a targeted compatibility check, not a complete description of the API.
Rank #3
Where OpenAPI validation fits
If your team maintains an OpenAPI description and needs to check provider conformance to that documented surface, use schema-based validation as well. MockServer describes importing Pact contracts and generating representative requests from OpenAPI, then checking responses against specified schemas. This can test documented shapes across representative requests, while a consumer-driven contract focuses on concrete interactions used by particular clients.
- Use consumer-driven contracts to check whether the provider still meets the request-and-response expectations of known consumers.
- Use OpenAPI/schema validation to check whether provider behavior conforms to the API shapes described in the maintained specification.
- Use provider functional tests to check whether the provider does the right thing for a request; contract tests are not a replacement for those tests.
Neither contract verification nor schema validation should be treated as a substitute for provider functional tests or production monitoring. Pact explains that consumer contract tests are intended to expose mistakes in consumer requests and response handling, and misunderstandings between consumer and provider; provider functional tests are responsible for whether the provider does the right thing for a request. See Pact’s consumer testing guidance.
Rank #4
A practical workflow for teams
- List the consumer’s dependencies. Identify the endpoint, method, meaningful request details, response fields and behavior the client actually uses.
- Write focused consumer tests. Use mocks for fast client feedback, but make each interaction protect a real compatibility need rather than asserting every possible provider detail. Pact’s consumer guidance describes this principle.
- Record and share the interactions. In Pact’s documented HTTP flow, consumer tests generate a JSON contract containing the interactions. Make that contract available to the provider team.
- Verify against the provider implementation. Replay the contract’s requests against a locally running provider. A passing consumer mock test alone is not this provider-side check. The workflow is described in the Pact JavaScript consumer guide.
- Add schema validation if the broader specification matters. Check representative provider responses against maintained OpenAPI schemas where that is part of your compatibility risk.
- Keep provider functional tests and monitoring in place. They address correctness and production behavior beyond the recorded consumer interactions or schema checks.
How to roll out an intentional breaking change
A contract failure can be an early warning that a provider change would break a consumer. For an incompatible change that must proceed, Pact’s FAQ describes an expand-and-contract rollout: add the replacement field or endpoint, migrate consumers, then remove the old interface after migration. Teams using a Pact Broker can check provider changes against both production and the latest consumer contracts, as described in the Pact FAQ.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Quick Recap
- Expand: deploy the replacement interface while retaining the existing one.
- Migrate: move consumers to the replacement and check their contracts during the transition.
- Contract: remove the old interface only after consumers have moved.
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.




