DEV.co
Open-Source Testing · httpmock

httpmock

httpmock is a lightweight HTTP mocking library for Rust that lets you create mock HTTP servers in tests. It supports request matching with regex and JSON, record-playback, HTTPS, and can run standalone via Docker.

Source: GitHub — github.com/httpmock/httpmock
664
GitHub stars
60
Forks
Rust
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryhttpmock/httpmock
Ownerhttpmock
Primary languageRust
LicenseMIT — OSI-approved
Stars664
Forks60
Open issues37
Latest releasev0.8.3 (2026-02-04)
Last updated2026-07-06
Sourcehttps://github.com/httpmock/httpmock

What httpmock is

A fully asynchronous Rust HTTP mocking library built with a fluent API for configuring mock responses and verifying requests. Provides synchronous and asynchronous APIs, custom matchers, fault simulation, and diff-based assertion reporting.

Quickstart

Get the httpmock source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/httpmock/httpmock.gitcd httpmock# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Unit and Integration Testing

Mock third-party HTTP services in Rust test suites to verify client code behavior without external dependencies. Parallel test execution and detailed assertion diffs make debugging failures quick.

API Client Development

Develop and test Rust API clients against predictable mock responses. Use record-playback to capture real API behavior, then replay in tests without rate limits or external service availability concerns.

Microservice Testing

Run the standalone Docker container to mock external HTTP dependencies in integration environments. Forward and proxy modes allow routing real traffic through the mock for inspection and fault injection.

Implementation considerations

  • Add httpmock to dev-dependencies in Cargo.toml; minimal setup required to start a mock server in tests.
  • Learn the fluent API for when/then mock configuration; expressive syntax scales well from simple stubs to complex matchers.
  • Configure parallel test execution carefully if tests use shared mock server state; httpmock supports parallelism but test isolation is your responsibility.
  • Use the detailed assertion error messages and diff output to debug mock mismatches; avoid brittle exact-match expectations where possible.
  • For record-playback workflows, plan storage and versioning of recorded HTTP exchanges; no built-in dependency management.

When to avoid it — and what to weigh

  • Non-Rust Projects — httpmock is Rust-specific. Non-Rust teams should evaluate language-appropriate alternatives like Mockoon, MSW, or Prism.
  • Production Traffic Mocking at Scale — Designed for test environments. Lacks features (clustering, persistence, advanced routing) needed for large-scale production traffic capture or replay.
  • Complex Protocol Mocking — Focused on HTTP/HTTPS. Projects requiring gRPC, WebSocket, or proprietary protocol mocking need specialized tools.
  • Stateful Workflow Simulation — Best for request-response matching. Scenarios requiring complex multi-request state machines or session management may require custom logic or dedicated workflow engines.

License & commercial use

MIT License. Permissive OSI-approved license allowing use, modification, and distribution with minimal restrictions. Includes no liability warranty.

MIT License permits commercial use in closed-source or open-source projects without modification. No per-seat or per-deployment fees. Requires review of your internal IP policies if integrating substantial custom logic.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

HTTPS support included for secure mock communication. No hardened security audits mentioned. Use in test environments only; verify any custom matchers do not leak sensitive data. Mocking library inherits risks of underlying async runtime; keep Rust and dependencies patched.

Alternatives to consider

mockito

Simpler synchronous API; smaller feature set; good for basic HTTP mocking in Rust but lacks advanced matching and standalone mode.

Mockoon (polyglot)

Standalone desktop/CLI tool; supports any language; no code integration required; trade-off is less programmatic control and no in-process testing.

Wiremock (JVM/Node.js)

Cross-language HTTP mocking; Docker-first design; strong enterprise adoption; Rust binding available but not as mature as httpmock.

Software development agency

Build on httpmock with DEV.co software developers

Evaluate httpmock for your test suite. Start with a small integration test, review the fluent API and assertion clarity, then assess fit for your team's testing strategy.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

httpmock FAQ

Can I use httpmock in production?
No. httpmock is designed for testing and development. For production traffic mocking or service virtualization, use enterprise tools like Mockoon or Wiremock with proper persistence and clustering.
Does httpmock support WebSockets or gRPC?
No. httpmock focuses on HTTP/HTTPS mocking. For WebSocket or gRPC, integrate specialized libraries or use separate mocking tools.
Can multiple tests run in parallel against the same mock server?
Yes. httpmock supports parallel test execution. Ensure each test either uses isolated mock servers or manages shared state carefully to avoid assertion conflicts.
Is there a commercial support or SLA?
Not clearly stated in the project data. Community support is available via Discord and GitHub issues. Commercial backing is unknown; verify directly with maintainer if needed.

Work with a software development agency

From first prototype to production, DEV.co delivers software development services around tools like httpmock. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source testing and beyond.

Ready to streamline your Rust testing?

Evaluate httpmock for your test suite. Start with a small integration test, review the fluent API and assertion clarity, then assess fit for your team's testing strategy.