WireMock vs Pact
WireMock and Pact answer different questions. WireMock simulates an API so you can test a consumer in isolation: stub responses, match requests, add latency and faults. Pact checks that the real provider still satisfies what each consumer actually uses, by generating a contract from consumer tests and verifying it on the provider side. Most microservice teams need both.
- WireMock
- An open-source API mock server that stubs HTTP responses, matches requests, records real traffic, injects faults and runs as a Java library, standalone JAR or Docker container.
- Pact
- A code-first consumer-driven contract testing tool: consumer tests generate a contract, the provider verifies it, and a broker tracks which versions are safe to deploy.
How do WireMock and Pact compare?
| Dimension | WireMock | Pact |
|---|---|---|
| What it verifies | WireMockThat your code behaves correctly against responses you defined | PactThat the provider actually returns what each consumer relies on |
| Where the truth lives | WireMockIn your stubs, which can drift from the real API without anyone noticing | PactIn a contract generated from consumer tests and verified against the provider |
| Who runs what | WireMockThe consumer team runs its tests against the mock | PactThe consumer test produces a pact; the provider build verifies it |
| How it runs | WireMockJava library, standalone JAR, Docker, an npm package, or WireMock Cloud | PactLibraries in more than ten languages, plus the Pact Broker or PactFlow |
| Languages | WireMockJava and JVM first; Python, Node.js, Go, Rust and others through clients | PactJavaScript, JVM, .NET, Go, Python, Swift, Ruby, PHP, Rust, C++ and more |
| Protocols | WireMockHTTP and HTTPS, including proxying to a real API | PactHTTP and message-based systems; gRPC, Avro and others through plugins |
| Beyond happy paths | WireMockFault injection, latency, response templating, record and playback | PactContract by example: each interaction is a concrete request and response pair |
| Deployment safety | WireMockNone; a mock cannot tell you the real API changed | Pactcan-i-deploy checks the broker before a version ships |
| Licence | WireMockOpen source, Apache 2.0; WireMock Cloud is commercial | PactOpen source, MIT; PactFlow is commercial |
When should you choose WireMock, and when Pact?
Choose WireMock when
- You need to test a consumer against responses the real API cannot easily produce: errors, timeouts, slow responses.
- The upstream API is third-party, unavailable in test, or costs money per call.
- You want fast, deterministic component tests for a service with many dependencies.
- You need to record real traffic once and replay it in CI.
Choose Pact when
- Several teams own the services and integration breakages surface late.
- You want to know before deploying whether a provider change breaks a consumer.
- End-to-end environments are slow, flaky or contested and you want to retire some of them.
- The provider is owned in-house and can run a verification step in its own build.
How does WireMock vs Pact come up in QA interviews?
This is a senior question because it is really about what your tests prove. A candidate who says WireMock and Pact are alternatives has not felt the failure that Pact prevents: a mock that kept passing after the real API changed. Say what each tool verifies, and where you have used both.
- 01You have thorough WireMock tests and the provider ships a breaking change. What happens to your tests, and what would have caught it?
- 02Explain consumer-driven contract testing and why the consumer, not the provider, writes the contract.
- 03Where do stubs and contracts live in your pipeline, and what does can-i-deploy actually check?
- 04When is contract testing not worth its overhead?
No account needed · Scored in under a minute against a senior rubric
Common questions about WireMock vs Pact
Is Pact a replacement for WireMock?
No. Pact verifies compatibility between a consumer and its provider; WireMock simulates a provider so the consumer can be tested alone. A Pact consumer test uses a mock service to record the interactions, but that mock is only the recording device. Teams typically keep WireMock for edge cases and use Pact to guard the integration.
Does WireMock do contract testing?
Not by itself. WireMock stubs are written by the consumer team and are never checked against the real provider, so they can drift silently. Contract testing adds the provider-side verification, which is what Pact provides.
Is Pact only for microservices?
It is most valuable where several teams own services that call each other and integration environments are expensive. Pact also covers message-based systems, not just HTTP. For a single team owning both sides, a shared integration test may be simpler.
Which should I learn first?
WireMock, because stubbing an API is a daily task in automation and it takes an afternoon. Learn Pact when you work on a system with multiple teams, and be ready to explain the consumer-provider flow and the broker in interviews for senior SDET roles.
Where was this checked?
Ready to be asked about WireMock or Pact?
Practice explaining the trade-off to an interviewer who knows both.
Join 500+ QA engineers already practicing with AssertHired.
A test passes locally but fails in CI about one run in five. Walk me through what you check first, and why.
Scored on the same four dimensions as the real thing: Technical accuracy · Coverage · Clarity · Best practices.
Rather skip ahead? Create a free account