# Service virtualization

> Service Virtualization: What It Is and When to Use It. Canonical page: <https://zapple.tech/glossary/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.

## How does a virtual service differ from a stub, a mock or the real thing?

You have several ways to deal with a dependency in a test. Which one fits depends on how much of the dependency's behavior you need.

| Option | Who maintains it | What it can simulate | Where it misleads |
|:--|:--|:--|:--|
| Stub | The test author, inside one test | A fixed response | Never changes, so it hides new fields and errors |
| Mock | The test author, per test or per suite | Responses plus checks that a call was made | Encodes what you believe the service does |
| Virtual service | A named owner, shared by teams | State, latency, faults, many endpoints | Drifts from the real service if not refreshed |
| Real dependency in a container | The team, from an image | Everything, as it really behaves | Only works for things you can run, and may be slow |
| Shared test environment | Another team or ops | The real system, with its real instability | Down, in use or changed by someone else |

This page uses "virtual service" for the shared, maintained kind. Tools use these words loosely, so check what a product means before comparing offers. Service Virtualization is also the name of a Broadcom product, which its [product page](https://www.broadcom.com/products/software/app-dev/service-virtualization) describes as letting you "capture and simulate the behavior of constrained or unavailable systems". This page covers the technique with any tool.

Tool documentation shows what the simulations are for. [WireMock](https://wiremock.org/docs/overview/) says it can help you "isolate yourself from flakey 3rd parties and simulate APIs that don't exist yet". [Hoverfly](https://docs.hoverfly.io/en/latest/) lists simulating "network latency, random failures or rate limits" to test edge cases. [Microcks](https://microcks.io/documentation/overview/what-is-microcks/) describes simulating complex distributed environments and validating components in isolation. These are the projects' own descriptions.

## When is service virtualization worth it, and when is a mock enough?

A mock is enough when one team tests one call against a well-understood service and the response rarely changes. Virtualization earns its upkeep in three situations:

- **The dependency costs money or has limits.** A third-party system that bills per call or throttles requests cannot take a nightly suite.
- **The dependency does not exist yet.** Teams build against an agreed interface while the other side is still being written.
- **You need cases the real service will not give you.** Timeouts, slow responses, malformed replies and partial outages are hard to cause on demand in a real system.

The cost is people. Someone owns the simulation, updates it when the real service changes, and answers questions when a test fails. Weigh that against what the shared environment costs you today in waiting and flaky runs; our [continuous testing in DevOps](/blog/test-automation-frameworks/how-to-use-continuous-testing-in-devops/) post covers where those waits show up. If you test a chain of services, [integration testing services](/services/integration-testing-services/) is the matching page.

If the dependency is something you can run, skip the simulation. [Testcontainers](https://testcontainers.com/guides/introducing-testcontainers/) describes starting real services in containers so tests run "without mocks or in-memory services". A real database in a container is simpler than a virtual one.

The data inside those dependencies is a separate problem; see [test data management](/glossary/test-data-management/). Ryan Papineau of Alaska Airlines covers both topics in a [recorded conference talk](/blog/aqa-process/ryan-papineau-alaska-airlines-service-virtualization-and-test-data-management-the-journey/).

## What goes wrong with virtual services?

The main failure is drift. The simulation says one thing, the real service has changed, and your tests pass against a version of the world that no longer exists. Three habits limit it:

1. **Give each virtual service an owner and a refresh trigger**, such as a change to the real service's specification.
2. **Record from the real service where you can**, then review what was captured, instead of writing every response by hand.
3. **Pair it with contract tests.** The [Pact documentation](https://docs.pact.io/) argues that without contract testing, the only way to know applications work together is "expensive and brittle integration tests". A contract checks that the simulation and the real service agree; see [contract testing](/glossary/contract-testing/). Keep a small set of end-to-end checks against the real dependency as well.

Another trap is trust. A virtual service that always answers politely will not show you how your code reacts to a real outage, so script the bad days on purpose. For the pipeline around this, see our guide to a [QA automation pipeline](/blog/types-of-automation-testing/guide-to-creating-qa-automation-pipeline/) and [API test automation](/blog/types-of-automation-testing/what-is-api-test-automation/).

## What does Zapple.Tech do about it?

If you are unsure which dependencies are worth simulating, 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](/services/audit-and-assessment/) page.

Tell us about your dependencies in the form below.

## FAQ

### What is service virtualization?

Service virtualization is a technique that replaces a dependency of the system under test with a simulated service that returns realistic responses. The dependency may be unavailable, costly per call, slow or not built yet. The test then runs against the simulation, and the simulation can also produce delays and failures on demand.

### What is the difference between service virtualization and mocking?

The line is blurry and tools use the words loosely. In practice a mock is a small, per-test stand-in set up in the test code. A virtual service is a shared, longer-lived simulation of a whole dependency, often run as its own server, that many tests and teams use and that is kept up to date.

### What is the difference between service virtualization and API mocking tools?

Many API mocking tools can also do the job of service virtualization, because the technique does not need a special product. The difference is the scope: a handful of canned responses for one test, or a maintained simulation of a dependency with state, latency and fault cases that a team relies on.

### When should you not virtualize a service?

Do not virtualize a dependency you can run for real at low cost, for example a database in a container. Avoid it when nobody will keep the simulation current, because a stale virtual service passes tests the real service would fail. Keep a few tests against the real thing.

## Sources

- [Broadcom, Service Virtualization product page (current page, undated, read 2026-12-06)](https://www.broadcom.com/products/software/app-dev/service-virtualization)
- [WireMock documentation, Overview (current docs)](https://wiremock.org/docs/overview/)
- [Hoverfly documentation, What is Hoverfly? (current docs)](https://docs.hoverfly.io/en/latest/)
- [Microcks documentation, What is Microcks? (current docs)](https://microcks.io/documentation/overview/what-is-microcks/)
- [Testcontainers guides, Introducing Testcontainers (current docs)](https://testcontainers.com/guides/introducing-testcontainers/)
- [Pact documentation, Introduction (last updated 2026-12-02)](https://docs.pact.io/)
