FREEDOM251

Freedom251 › API Mocking Tools

MockWebServer

Free plan Android

Visit MockWebServer Alternatives Pricing

MockWebServer's own site

What MockWebServer is

MockWebServer is a free, open-source library for testing apps that make HTTP, HTTPS, or HTTP/2 requests, particularly apps using the OkHttp client. Developers can supply responses and inspect the requests their apps send. Recorded requests expose details such as method, path, HTTP version, body, headers, and chunk sizes. Tests can queue responses in order or use a Dispatcher to choose a response policy for each request. Mock responses can be throttled to imitate slow network conditions, and socket policies can keep a connection open, disconnect during a request or response body, 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. The library is licensed under Apache License, Version 2.0, and supports local deployment. The project describes its scope as internal and basic client testing, not a full-featured standalone HTTP testing library, and says it is not actively developed for new features. It suggests MockServer when requirements exceed that scope.

Who it suits

MockWebServer suits developers writing internal or basic tests for apps that use OkHttp or make HTTP, HTTPS, or HTTP/2 requests. It is less suited to projects needing a full standalone testing library.

What it does well

  • Tests HTTP, HTTPS, and HTTP/2 clients.
  • Responses can be scripted or dispatched by policy.
  • Can simulate slow networks and socket failures.
  • Free under Apache License 2.0.

What to know first

  • Not a full-featured standalone testing library.
  • Not actively developed for new features.

Limits

The free library is intended for internal and basic client testing. The project says it is not a full-featured standalone HTTP testing library and is not actively developed for new features.

Plans

PlanBilled and limitsPrice
Open sourceApache License 2.0Free
MockWebServerNo price stated · Test library for HTTP, HTTPS, and HTTP/2 clients · Available from Maven CentralFree

As square.github.io lists them, read 4 Oct 2026. The maker's own page has the final word.

Getting started

  1. Add testImplementation("com.squareup.okhttp3:mockwebserver3:5.5.0") from Maven Central.
  2. Use the library in tests for an app that uses the OkHttp client.
  3. Supply canned responses in sequence or use a Dispatcher to apply a response policy.
  4. Inspect recorded requests to verify method, path, HTTP version, body, and headers.
  5. Use throttling or socket policies to simulate network conditions as needed.

Verdict

MockWebServer offers request capture and controllable responses for basic client tests. Consider its stated scope limit if your testing needs go beyond that, as the project points users toward MockServer.

Questions

How much does MockWebServer cost?

The listed Open source and MockWebServer plans are both free.

Is MockWebServer open source?

Yes. The README states that it is licensed under Apache License, Version 2.0.

Which protocols can it test?

Project documentation describes testing HTTP, HTTPS, and HTTP/2 clients.

How do I add MockWebServer to a project?

The documented test dependency is com.squareup.okhttp3:mockwebserver3:5.5.0, available through Maven Central.

What is its intended scope?

The project describes it for internal and basic testing of apps using OkHttp. It suggests MockServer when needs exceed that scope.

Can it generate different responses for requests?

Yes. Responses can be queued in order or produced by a Dispatcher that applies a policy to each request.

Facts from MockWebServer's own pages

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

Where MockWebServer stands on Freedom251

Look at these too