We use analytics to count visits and form use. It is on unless you reject it. We show no ads on this site.

Glossary

Service virtualization

Published . Last updated . Published by Zapple.Tech, founded by the founders of CodeceptJS and Codeception, open-source testing frameworks.

Also called
API virtualization, virtual services
Published
Updated
Related service
Integration testing
Definition

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 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 says it can help you “isolate yourself from flakey 3rd parties and simulate APIs that don’t exist yet”. Hoverfly lists simulating “network latency, random failures or rate limits” to test edge cases. Microcks describes simulating complex distributed environments and validating components in isolation. These are the projects’ own descriptions.

Service virtualization: the system under test calls a virtual service that answers like the real dependency, which is slow, costly or not built yet; a named owner keeps the virtual service in step with the real one

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 post covers where those waits show up. If you test a chain of services, integration testing services is the matching page.

If the dependency is something you can run, skip the simulation. 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. Ryan Papineau of Alaska Airlines covers both topics in a recorded conference talk.

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 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. 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 and 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 page.

Tell us about your dependencies in the form below.

  • Test data management

    Test data management is how a team creates, protects, shares and refreshes the data its tests run on. Done well, tests get realistic data on demand and no real customer data sits in test systems. Done badly, releases wait for environments and tests fail for reasons that have nothing to do with the code.

  • 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.

  • Contract testing

    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.

All terms in the glossary

Test with AI

Integration testing

Integration testing services: automated tests for how your services, databases and third-party systems work together, run in CI. Start with a one-week audit.

See the service

Questions about service virtualization

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.

Request a QA audit quote

Tell us what you ship and what worries you.

What happens after you send this

  1. You send the form: your situation and what you need tested, then your name and work email.
  2. Within one business day, we reply with a suggested first step, its scope, timeline and a quote.
  • Fixed scope
  • You decide after each step
  • The tests live in your repository
  • An NDA signed before access

“They helped us to close the positions and consult our team how to proceed further. High-quality quick feedbacks with the deep checking of the required tasks, professional approach, great understanding of the company's technologies and product, detailed reports.”

Kristina Lavrentieva, Manager at keepgo.com, Israel
  • Rated 4.9 out of 5 on Clutch, from 7 client reviews
  • 42 completed test automation and infrastructure projects
  • Founded by the founders of CodeceptJS and Codeception, open-source testing frameworks

Request a QA audit quote

    What is closest to your situation?
    Optional. The product, the platforms, how often you release, what broke last.

    You decide after our reply whether to go ahead.

    Prefer to talk first? Book a call

    One-week QA audit · written report

    Request a QA audit quote