mockall_double
A double test adapter that works well with Mockall.
Overview
Mockall can easily create a mock version of a struct. But how does one
convince the code under test to use the mock struct instead of the real one?
In Rust, it's necessary to replace the real struct at compile time. That's
very easy to do with a few #[cfg(test)]
statements. But mockall_double makes
it even easier.
Usage
Typically mockall
is only used by unit tests, so it can be a dev-dependency.
But mockall_double
must be a full dependency. To use it this way, add this to
your Cargo.toml
:
[]
= "0.3.1"
[]
= "0.12.0"
Then use it like this:
use double;
use Foo;
See the API docs for more information.
Minimum Supported Rust Version (MSRV)
mockall_double
is tested with the same MSRV as Mockall itself. Currently,
that's Rust 1.42.0. mockall_double
's MSRV will not be changed in the future
without bumping the major or minor version.
License
mockall_double
is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0).
See LICENSE-APACHE, and LICENSE-MIT for details
Acknowledgements
mockall_double
is inspired by Jason Grlicky's
double crate, but tweaked to work better
with Mockall's naming conventions.