14 releases

0.4.4 Jun 4, 2021
0.4.3 Apr 12, 2021
0.3.4 Mar 23, 2021
0.2.2 Feb 19, 2021

#44 in Testing

Download history 15/week @ 2021-02-20 18/week @ 2021-02-27 27/week @ 2021-03-06 36/week @ 2021-03-13 33/week @ 2021-03-20 43/week @ 2021-03-27 61/week @ 2021-04-03 51/week @ 2021-04-10 27/week @ 2021-04-17 20/week @ 2021-04-24 17/week @ 2021-05-01 1/week @ 2021-05-08 28/week @ 2021-05-15 6/week @ 2021-05-29 25/week @ 2021-06-05

114 downloads per month




Build status Crates.io

use it

You can use stubr as a cli for serving Wiremock stubs on a local server or as proxy for recording http traffic into json stubs.
To get a list of all available options run stubr --help

The simplest usage is for serving Wiremock stubs under a directory.
Example for a project exposing contracts using Spring Cloud Contract

./gradlew generateClientStubs
stubr build/stubs/META-INF/com.ecorp/my-app/SNAPSHOT/mappings
 > + mounted "./build/stubs/META-INF/com.ecorp/my-app/SNAPSHOT/mappings/find-all.json"
 > + mounted "./build/stubs/META-INF/com.ecorp/my-app/SNAPSHOT/mappings/find-by-id.json"
 > Started stubr in 50ms on


arg about examples
[dir] Folder containing stubs or individual stub. stubr ./my-app-stubs or stubr ./my-app-stubs/ping.json
--root-dir Directory containing a mappings folder with all stubs. Equivalent to Wiremock's one. Has precedence over [dir] stubr --root-dir ./my-app-stubs
--port Server port. Defaults to random port. stubr --port 8080 or stubr -p 8080
--delay Global delay duration applied to all stubs (supersedes any locally defined delay). stubr --delay 2s or stubr -d 1m or stubr -d 100ms
--latency Delay added to any locally defined delay. Simulates network latency. stubr --latency 2s or stubr -l 1m or stubr -l 100ms
completion Generates & installs bash or zsh completion scripts stubr completion bash or stubr completion zsh
--help Displays help. stubr help or stubr -h for short help. stubr --help for long help
--version Displays stubr version. stubr -V or stubr --version

Also available as a crate.

install it

with precompiled binaries (linux & osx)

curl -L https://github.com/beltram/stubr/releases/latest/download/stubr-linux.tar.gz | tar xz - -C /usr/local/bin
macos (Catalina):

NOTE: Big Sur users are recommended to install with cargo or from source

curl -L https://github.com/beltram/stubr/releases/latest/download/stubr-macos.tar.gz | tar xz - -C /usr/local/bin

with cargo

cargo install stubr-cli

from source (linux & osx)

git clone --depth 1 https://github.com/beltram/stubr.git && cd stubr && cargo build --release && mv target/release/stubr /usr/local/bin/

then generate completion

Completion files generation is currently supported for bash and zsh. Stubr cli provides a completion command to generate and install them in a standard location.

stubr completion zsh
# or
stubr completion bash


In order to record http traffic, stubr can act as a proxy to dump this traffic into json stubs on your local filesystem. Recording can be started with the stubr record command. Stubs will be grouped by hosts. You can then play them back using stubr.

arg about examples
--port Proxy port. Defaults to 3030. stubr --port 3031 or stubr -p 3031
--output File path where recorded stubs are stored. Default to current directory. stubr --port record-1 or stubr -o record-1

Also available as a crate for recording traffic in unit tests.


A very simple benchmark comparing stubr to wiremock is available here


~501K SLoC