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.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | httpmock/httpmock |
| Owner | httpmock |
| Primary language | Rust |
| License | MIT — OSI-approved |
| Stars | 664 |
| Forks | 60 |
| Open issues | 37 |
| Latest release | v0.8.3 (2026-02-04) |
| Last updated | 2026-07-06 |
| Source | https://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.
Get the httpmock source
Clone the repository and explore it locally.
git clone https://github.com/httpmock/httpmock.gitcd httpmock# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
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.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
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.
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.coRelated 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?
Does httpmock support WebSockets or gRPC?
Can multiple tests run in parallel against the same mock server?
Is there a commercial support or SLA?
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.