A simple yet powerful HTTP mocking library for Rust, featuring a fluent API, request matching, and standalone Docker support.
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.
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.
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.
HTTP mocking library for Rust
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.
Built-in support for regex, JSON, cookies, and custom matchers allows precise control over mock expectations, reducing false positives in complex tests.
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.
Features like network delay simulation and detailed error diffs help test application resilience and debug mismatched requests efficiently, as highlighted in the verification tools.
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.
Focused solely on HTTP, so it cannot mock other network protocols like gRPC or WebSockets without additional tools or workarounds.
Features like file-based mocks and standalone mode require additional configuration, such as YAML parsing or Docker setup, increasing initial setup time.
🐇 Fuzzing Rust code with American Fuzzy Lop
A powerful mock object library for Rust
The Declarative Data Generator
Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.