Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Rust
  3. httpmock

httpmock

MITRustv0.8.3

A simple yet powerful HTTP mocking library for Rust, featuring a fluent API, request matching, and standalone Docker support.

Visit WebsiteGitHubGitHub
657 stars60 forks0 contributors

What is httpmock?

httpmock is a comprehensive HTTP mocking library for Rust designed to simplify testing of applications that rely on external HTTP services. It provides a lightweight mock server that can simulate real HTTP responses, enabling developers to write reliable and isolated tests without depending on live endpoints.

Target Audience

Rust developers writing integration or unit tests for applications that make HTTP requests to external APIs or services, such as web clients, microservices, or API consumers.

Value Proposition

Developers choose httpmock for its expressive, fluent API combined with powerful features like advanced request matching, fault simulation, and detailed verification tools, making it both easy to use for simple cases and capable of handling complex testing scenarios.

Overview

HTTP mocking library for Rust

Use Cases

Best For

  • Testing Rust applications that integrate with third-party HTTP APIs without hitting live endpoints.
  • Simulating network failures, delays, or HTTP errors to test application resilience and error handling.
  • Writing integration tests for microservices or distributed systems that require isolated HTTP communication.
  • Recording and replaying HTTP interactions with external services for consistent test execution.
  • Defining reusable mock configurations via YAML files for complex or repetitive test scenarios.
  • Running a standalone mock server via Docker for integration testing in CI/CD pipelines or across different services.

Not Ideal For

  • Projects that only need simple, in-memory HTTP mocks without a standalone server for unit testing.
  • Testing non-HTTP network protocols like gRPC, WebSockets, or raw TCP connections.
  • Environments with strict resource constraints where running an additional mock server process is prohibitive.
  • Teams preferring zero-dependency mocking solutions that integrate directly into test runners without external setup.

Pros & Cons

Pros

Expressive Fluent API

Provides a chainable, intuitive API for defining mocks, as shown in the example with `when.method(GET).path(...).query_param(...)`, making test code readable and maintainable.

Advanced Request Matching

Built-in support for regex, JSON, cookies, and custom matchers allows precise control over mock expectations, reducing false positives in complex tests.

Standalone and Docker Support

Can run as a separate mock server with an official Docker image, enabling integration testing across services or in CI/CD pipelines without code changes.

Fault Simulation and Verification

Features like network delay simulation and detailed error diffs help test application resilience and debug mismatched requests efficiently, as highlighted in the verification tools.

Cons

Server Overhead

Running a lightweight mock server adds process and resource overhead compared to purely in-memory mocking libraries, which can slow down test execution for simple cases.

HTTP-Only Limitation

Focused solely on HTTP, so it cannot mock other network protocols like gRPC or WebSockets without additional tools or workarounds.

Setup Complexity for Advanced Features

Features like file-based mocks and standalone mode require additional configuration, such as YAML parsing or Docker setup, increasing initial setup time.

Frequently Asked Questions

Quick Stats

Stars657
Forks60
Contributors0
Open Issues18
Last commit1 month ago
CreatedSince 2019

Tags

#serde#integration-testing#async#mock-server#testing#mock#docker#test#test-framework#rust#http-mocking#yaml-configuration

Built With

s
serde
R
Rust
r
regex
D
Docker

Links & Resources

Website

Included in

Rust56.6k
Auto-fetched 15 hours ago

Related Projects

afl.rsafl.rs

🐇 Fuzzing Rust code with American Fuzzy Lop

Stars1,821
Forks115
Last commit3 days ago
mockallmockall

A powerful mock object library for Rust

Stars1,811
Forks79
Last commit9 days ago
synthsynth

The Declarative Data Generator

Stars1,482
Forks110
Last commit1 year ago
trusttrust

Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows

Stars1,276
Forks59
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub