A procedural macro that can swap in mock objects, dummy objects, or other test doubles only when testing. Requires Nightly Rust.
There are many limitations at present:
use blah::{foo, bar};
use blah::{*, something::{foo, bar}};
To use, add the following to your Cargo.toml
:
toml
[dependencies]
test_double = "0.1.0"
Note that this crate has not yet reached version 1.0, so the API may change drastically between releases.
The substituted name defaults to the original name, postfixed with "Mock":
```rust
use ::image::ImageManager;
// Expands to:
use ::image::ImageManager;
use ::image::ImageManagerMock as ImageManager; ```
If you'd like to change the subsituted name, you can do so:
```rust
use ::image::ImageManager;
// Expands to:
use ::image::ImageManager;
use ::image::IMDummy as ImageManager; ```
If you'd like to substitute multiple types at once, you can use the function-like macro. Note that this does not support changing the substituted name yet.
```rust test_double! { use ::image::ImageManager; use ::texture::TextureManager; }
// Expands to:
use ::image::ImageManager;
use ::image::ImageManagerMock as ImageManager;
use ::texture::TextureManager;
use ::texture::TextureManagerMock as TextureManager; ```