DEV.co
Open-Source Testing · lipanski

mockito

Mockito is a Rust library for creating and running HTTP mocks locally, designed to simplify integration testing and offline development. It supports both sync and async workflows, parallel test execution, and multiple concurrent mock servers.

Source: GitHub — github.com/lipanski/mockito
777
GitHub stars
66
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
Repositorylipanski/mockito
Ownerlipanski
Primary languageRust
LicenseMIT — OSI-approved
Stars777
Forks66
Open issues7
Latest release1.7.2 (2026-02-02)
Last updated2026-02-23
Sourcehttps://github.com/lipanski/mockito

What mockito is

Mockito provides a pool-based HTTP mocking server for Rust with HTTP/1 and HTTP/2 support, comprehensive request matchers (regex, JSON, query parameters), spy/assertion capabilities, and both synchronous and asynchronous APIs. It requires Rust 1.85.0+.

Quickstart

Get the mockito source

Clone the repository and explore it locally.

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

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

Best use cases

Integration Testing

Mock external HTTP services in integration tests to verify client code behaves correctly without depending on live endpoints. Enables reliable, repeatable test suites.

Multi-Service Local Development

Simulate multiple downstream services locally by running separate mock servers concurrently. Useful for developing microservice-heavy applications without full infrastructure.

Async/Await Testing

Test async Rust code that makes HTTP calls using native async interfaces. Supports both Tokio and other async runtimes without blocking.

Implementation considerations

  • Minimum Rust version is 1.85.0; verify all team members and CI pipelines meet this requirement.
  • Use `_async` methods explicitly for async tests; mixing sync/async patterns incorrectly will cause runtime panics.
  • Mock assertion failures display colored diffs by default; disable via feature flags if colors are problematic in CI logs.
  • Each test requesting a new server from the pool incurs setup overhead; reuse servers when appropriate to speed up test suites.
  • Matchers support regex, partial JSON, and query parameters; test matcher logic carefully to avoid false positives/negatives.

When to avoid it — and what to weigh

  • Production Traffic Interception — Mockito is designed for test environments only. Do not use in production code paths or for intercepting real traffic to live services.
  • Heavy Performance Simulation — While capable, Mockito is optimized for testing, not realistic latency/throughput benchmarking. Use load-testing tools for that purpose.
  • Stateful Protocol Mocking — Limited support for complex stateful protocols beyond HTTP. If you need WebSocket or gRPC mocking, evaluate alternatives.
  • Non-Rust Codebases — Mockito is a Rust-native library. Cross-language or polyglot teams should consider language-agnostic mocking solutions.

License & commercial use

Licensed under MIT (MIT License), a permissive OSI-approved open-source license allowing commercial use, modification, and distribution with minimal restrictions.

MIT license explicitly permits commercial use in production codebases. No proprietary restrictions on derivatives or commercial software that depend on this library. However, review your organization's compliance requirements and ensure proper attribution per MIT license terms.

DEV.co evaluation signals

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

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

Mockito runs local HTTP servers in test environments and should never touch production traffic. No sensitive data handling noted. If mocks are inadvertently exposed or test code leaks to production, review all mock endpoints for accidentally embedded secrets. Standard Rust memory safety applies; no known security advisories mentioned in provided data.

Alternatives to consider

wiremock-rs

Similar HTTP mocking for Rust with a different API design and community adoption; evaluate if wiremock-rs better fits your matcher/assertion patterns.

httptest

Lightweight alternative focused on simpler HTTP mocking; consider if Mockito's feature set (HTTP/2, colored diffs, multi-server) is overkill for your tests.

mockserver (non-Rust)

Language-agnostic HTTP mocking; relevant if your stack includes non-Rust services or you prefer a separate service for cross-language testing.

Software development agency

Build on mockito with DEV.co software developers

Mockito eliminates external API dependencies in your test suite. Add it to your Cargo.toml, write cleaner tests, and ship faster. Check the docs.rs guide to get started.

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.

mockito FAQ

Can I use Mockito to mock external APIs during development without running tests?
Yes. Mockito provides a stand-alone server mode via ServerOpts. You can run a dedicated server on a custom port (example in docs) and point your dev client to it manually.
Does Mockito support parallel test execution?
Yes, by design. Each test requests mocks from a pool of servers, isolating them. Run your test suite with `cargo test -- --test-threads=N` (N > 1).
What happens if a request doesn't match any mock?
Mockito returns an error and prints a colored diff of the unmatched request to help debugging. This is a feature for catching test issues quickly.
Is HTTP/2 fully supported?
Mockito advertises HTTP/1 and HTTP/2 support in features list; however, specific implementation details and known limitations are not detailed in provided data. Requires review if HTTP/2 is critical for your use case.

Work with a software development agency

DEV.co helps companies turn open-source tools like mockito into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source testing stack.

Ready to Simplify Your Rust HTTP Testing?

Mockito eliminates external API dependencies in your test suite. Add it to your Cargo.toml, write cleaner tests, and ship faster. Check the docs.rs guide to get started.