Service virtualisation with WireMock
Use a stand-in web service to test set replies, slow replies and faults. Check what it received, and keep its limits clear.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a stunt double. A film crew plans a fall before it starts the scene. The double follows that plan. It does not act out every part of the real actor's life.
puts a in place of a real one. WireMock can play that part for web calls. Tom tests Daily List, a to-do list app. He points its plan lookup at his own test server.
A pairs a request rule with a reply. Tom gives the stand-in a rule for user 7. Its reply says the plan is Pro. The app should show Pro after it reads that reply.
means making a chosen failure happen on purpose. Tom can arrange a slow reply or a server error. He checks what the app does in each case.
The result has a limit. A good test shows how the app handles the chosen scene. It does not prove that the real plan service works, or that every failure is covered. Keep separate checks against the agreed service rules and an approved real test service.
PLAIN WORDS · 1 in this section
- stub
- a simple fake part that gives fixed answers
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Test an app with chosen service replies and faults.
- Match
- Reply
- Fault
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The stunt double | The stand-in service |
| A cue | A stub mapping |
| Telling it to fall | Fault injection |
| The real actor | The real service |
WHERE THIS PICTURE STOPS
- A stand-in follows only the rules written for it, not the whole real service.
- A passing scene does not prove the real service works.
- A recorded scene does not cover every request or failure.
HOOK
Choose, call, check.
TELL A FRIEND
A stunt double follows the chosen scene; a stand-in follows the chosen service rules.
OFTEN MIXED UP WITH Stand-ins for other systems: stubs and mocks. That topic explains stubs and mocks as ideas. This one uses a tool to run a .
Sources & standards — 2 sources
- Market practice
Stubbing (WireMock documentation) ↗ — WireMock · Basic stubbing, stub priority, unmapped replies, reset and reset-to-default: current official page opened 8 November 2026. Local examples separately checked with WireMock Java 3.13.1.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. Supplement6November2026: actual current and archived2.x stubbing pages opened; priority then most-recent matching stub; reset paths also documented in2.x. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
8 November 2026: actual live WireMock Java Basic Stubbing and complete Stub Priority section/examples opened. Request mappings select configured responses; no installed-version or every-feature claim.
WireMock topic review, 8 November 2026: Basic stubbing, stub priority, unmapped replies, reset and reset-to-default: current official page opened 8 November 2026. Local examples separately checked with WireMock Java 3.13.1.
Version-specific correction: the general Reset paragraph says all mappings are removed, but WireMock Java 3.13.1 resetAll reloads defaults. See v945-wiremock-3131-reset-source and the local runtime tests. Do not infer an empty mapping list when files are present.
- Market practice
Simulating faults (WireMock documentation) ↗ — WireMock · Per-stub fixed delays and bad responses. Current official page opened 8 November 2026; delays are milliseconds and connection faults differ from status replies.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
WireMock topic review, 8 November 2026: Per-stub fixed delays and bad responses. Current official page opened 8 November 2026; delays are milliseconds and connection faults differ from status replies.
PRACTISE AND KEEP
Sources for this topic — 8 sources
- Market practice
Stubbing (WireMock documentation) ↗ — WireMock · Basic stubbing, stub priority, unmapped replies, reset and reset-to-default: current official page opened 8 November 2026. Local examples separately checked with WireMock Java 3.13.1.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. Supplement6November2026: actual current and archived2.x stubbing pages opened; priority then most-recent matching stub; reset paths also documented in2.x. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
8 November 2026: actual live WireMock Java Basic Stubbing and complete Stub Priority section/examples opened. Request mappings select configured responses; no installed-version or every-feature claim.
WireMock topic review, 8 November 2026: Basic stubbing, stub priority, unmapped replies, reset and reset-to-default: current official page opened 8 November 2026. Local examples separately checked with WireMock Java 3.13.1.
Version-specific correction: the general Reset paragraph says all mappings are removed, but WireMock Java 3.13.1 resetAll reloads defaults. See v945-wiremock-3131-reset-source and the local runtime tests. Do not infer an empty mapping list when files are present.
- Market practice
Request matching (WireMock documentation) ↗ — WireMock · URL matching: path and query versus path only, plus request attributes. Current official page opened 8 November 2026.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
WireMock topic review, 8 November 2026: URL matching: path and query versus path only, plus request attributes. Current official page opened 8 November 2026.
- Market practice
Simulating faults (WireMock documentation) ↗ — WireMock · Per-stub fixed delays and bad responses. Current official page opened 8 November 2026; delays are milliseconds and connection faults differ from status replies.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
WireMock topic review, 8 November 2026: Per-stub fixed delays and bad responses. Current official page opened 8 November 2026; delays are milliseconds and connection faults differ from status replies.
- Market practice
Verifying requests (WireMock documentation) ↗ — WireMock · Request journal, counts, unmatched requests, near misses and resetting the journal. Current official page opened 8 November 2026.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
WireMock topic review, 8 November 2026: Request journal, counts, unmatched requests, near misses and resetting the journal. Current official page opened 8 November 2026.
- Market practice
Running as a standalone process (WireMock documentation) ↗ — WireMock · Command-line options: bind address, no-request-journal and max-request-journal-entries. Current official page opened 8 November 2026.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
WireMock topic review, 8 November 2026: Command-line options: bind address, no-request-journal and max-request-journal-entries. Current official page opened 8 November 2026.
- Market practice
Stateful behaviour (WireMock documentation) ↗ — WireMock · Scenarios, Started state and POST /__admin/scenarios/reset. Current official page opened 8 November 2026.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. V27 supplement, 6 November 2026: relevant primary page sections actually opened; implementation-specific current product guidance, not universal standard. See full V27 audit for version and access scope.
8 November 2026: actual WireMock Java Scenarios section, Java/JSON example and reset operations opened. Models selected state transitions; not reproduction of an entire real service or actual WireMock execution.
WireMock topic review, 8 November 2026: Scenarios, Started state and POST /__admin/scenarios/reset. Current official page opened 8 November 2026.
- Market practice
Record and playback (WireMock documentation) ↗ — WireMock · Recording, snapshotting and generated mappings. Current official page opened 8 November 2026. Recordings capture observed interactions, not every possible service behaviour.
Recording, snapshotting and generated mappings. Current official page opened 8 November 2026. Recordings capture observed interactions, not every possible service behaviour. No new live traffic was recorded for this lesson.
- Market practice
Reset implementation in WireMock Java 3.13.1 ↗ — WireMock · WireMock Java 3.13.1 tagged ResetTask calls resetAll; WireMockApp resetAll calls resetToDefaultMappings, which clears mappings and requests then reloads defaults. Source opened and behaviour reproduced locally on 8 November 2026. This differs from the general Stubbing prose.
WireMock Java 3.13.1 tagged ResetTask calls resetAll; WireMockApp resetAll calls resetToDefaultMappings, which clears mappings and requests then reloads defaults. Source opened and behaviour reproduced locally on 8 November 2026. This differs from the general Stubbing prose. Route task: https://github.com/wiremock/wiremock/blob/3.13.1/src/main/java/com/github/tomakehurst/wiremock/admin/tasks/ResetTask.java
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.