Skip to content
SPECIFICTION
Get listed

MockWebServer

square.github.io

Free plan Android
Visit square.github.io
Spec score 7.7 #14 of 26 in API Mocking Tools

What it is

MockWebServer is a free, open-source Android test library for developers checking HTTP clients. It provides a scriptable local server where tests supply canned responses and inspect requests made during HTTP, HTTPS, or HTTP/2 calls. Recorded requests expose method, path, HTTP version, body, headers, and chunk sizes for verification. Responses can be queued in sequence or generated by a Dispatcher that applies a request-by-request policy. Tests can throttle responses to imitate slow networks, and socket policies can keep connections open, disconnect during request or response bodies, or send no response. The README includes Java and Kotlin examples. The documented dependency is com.squareup.okhttp3:mockwebserver3:5.5.0, available through Maven Central. MockWebServer is licensed under Apache License 2.0 and is intended for internal and basic testing of apps using OkHttp. The project says it is not a full-featured standalone HTTP testing library and is not actively developed for new features; it suggests MockServer when requirements exceed its scope.

Spec sheet

Purpose
MockWebServer is a library for testing HTTP, HTTPS, and HTTP/2 clients.Read 7 Oct 2026 · lysine.dev
Integrations
Optional artifacts provide JUnit 4 and JUnit 5 integrations, while the core mockwebserver3 module has no JUnit dependency.Read 7 Oct 2026 · lysine.dev
Security
The docs state that MockWebServer can test HTTP, HTTPS, and HTTP/2 clients; they do not state security certifications or compliance claims.Read 7 Oct 2026 · lysine.dev
Support
The project directs users to report issues encountered on GraalVM, but does not state a MockWebServer support plan or response time.Read 7 Oct 2026 · lysine.dev
License
The project page includes the Apache License, Version 2.0.Read 7 Oct 2026 · lysine.dev
Alternative
The project documentation suggests MockServer for users whose needs outgrow MockWebServer.Read 4 Oct 2026 · github.com
Distribution
The documented dependency is testImplementation("com.squareup.okhttp3:mockwebserver3:5.5.0"), available through Maven Central.Read 7 Oct 2026 · lysine.dev
Installation
The README lists the test dependency as com.squareup.okhttp3:mockwebserver3:5.5.0.Read 4 Oct 2026 · github.com
Intended audience
The project describes MockWebServer as being used for internal testing and basic testing of apps using the OkHttp client.Read 7 Oct 2026 · lysine.dev
Protocols
OkHttp describes MockWebServer as a library for testing HTTP, HTTPS, and HTTP/2 clients.Read 4 Oct 2026 · github.com
Request capture
Its API exposes recorded requests, including request method, target, version, body, and chunk sizes.Read 7 Oct 2026 · lysine.dev
Request verification
Recorded requests can be checked by method, path, HTTP version, body, and headers.Read 4 Oct 2026 · github.com
Response scripting
Responses can be queued in order or generated by a Dispatcher that applies a policy to each request.Read 4 Oct 2026 · github.com
Responses
It is a scriptable web server that replays supplied canned responses in sequence when requested.Read 7 Oct 2026 · lysine.dev
Scope limit
The project says MockWebServer is not a full featured standalone HTTP testing library and is not actively developed for new features.Read 7 Oct 2026 · lysine.dev
Simulated network conditions
Mock responses can be throttled to simulate a slow network for timeout and interactive testing.Read 4 Oct 2026 · github.com
Socket behavior
Socket policies include behaviors such as keeping a socket open, disconnecting during a request or response body, and sending no response.Read 7 Oct 2026 · square.github.io
Test coverage
It lets developers specify responses and verify requests made by an app during HTTP and HTTPS calls.Read 4 Oct 2026 · github.com
Test languages
The README provides example tests in both Java and Kotlin.Read 4 Oct 2026 · github.com

Plans and prices

MockWebServer Free No price stated · Test library for HTTP, HTTPS, and HTTP/2 clients · Available from Maven Central Read 7 Oct 2026 · lysine.dev
Open source Free Apache License 2.0 Read 4 Oct 2026 · github.com

Every MockWebServer plan and price →

Strong points and limits

Strong points

  • Tests HTTP, HTTPS, and HTTP/2 clients
  • Queues or dynamically generates responses
  • Verifies request methods, paths, bodies, and headers
  • Simulates slow networks and socket behavior
  • Free Apache License 2.0 library

Limits

  • Not a full-featured standalone HTTP testing library
  • Not actively developed for new features
  • Focused on internal and basic client testing

Who it suits

MockWebServer suits Android developers writing Java or Kotlin tests for OkHttp-based applications. It fits internal and basic HTTP client testing where scripted responses and request inspection are enough.

Verdict

MockWebServer offers local, scriptable control over responses and detailed request capture for client tests. Its documented scope is deliberately limited, so projects needing broader HTTP testing may need MockServer.

Where Specifiction places it

Alternatives to MockWebServerAll alternatives →