WireMock part 1: run it and write a first stub
Start WireMock on your own machine, save one mapping file with a request and a response, and call it with curl to see the answer you wrote.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a vending machine with a button code. You press a code and the same snack drops every time. The machine does not call a real shop. You stock it by loading a tray.
Tom is a tester at Daily List, a to-do list app. The real tasks service is slow and often busy. He needs one answer that does not change.
What it is: WireMock is a free tool that pretends to be an HTTP (Hypertext Transfer Protocol) service. You run it on your own machine. A is a small (JavaScript Object Notation) file with a request part and a response part. JSON is text with curly brackets and names in quotes. A WireMock start folder is where the server looks for a mappings folder and a __files folder. The WireMock admin address is a set of paths that start with /__admin. Those paths control the server. They are not the pretend API (application programming interface). WireMock is not the real tasks service. A stub answers what you wrote. It does not prove the real service is well.
Why it matters: A slow or busy partner blocks tests. Tom can start WireMock and write one stub so the tests get a stable answer. If he points the tests at the real partner instead, the run fails for reasons he does not control.
PLAIN WORDS · 3 in this section
- vending
- selling goods from a machine
- hypertext
- text that links to other pages
- 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 Register a valid stub and inspect admin state.
- Code
- Tray
- Snack
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The button code | The request |
| The snack that drops out | The response |
| The tray you load | The mapping file |
| The panel that lists the stock | The admin address |
WHERE THIS PICTURE STOPS
- A snack is real, but a stub answer is only written text.
- A machine stocks itself, but you load every mapping.
- A tray is fixed, but a mapping can be changed.
HOOK
Code in, snack out.
TELL A FRIEND
A code, a tray and a snack.
OFTEN MIXED UP WITH Service virtualisation with WireMock. That topic explains why a helps. This one starts WireMock and writes the first stub by hand.
PRACTISE AND KEEP
Sources for this topic — 2 sources
- Implementation-specific
Stubbing (WireMock documentation) ↗ — WireMock · Current Stubbing: request/response mapping, priority lower number/default5/latest matching at equal priority, explicit save mappings endpoint; opened6 November2026.
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.
- Implementation-specific
Running in Docker (WireMock documentation) ↗ — WireMock · Current Docker documentation example3.13.2: mounted mappings/__files under /home/wiremock; ephemeral --rm versus host storage; opened6 November2026.
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.
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.