[][src]Macro mockiato::mockable

macro_rules! mockable {
    () => { ... };
}

Generates a mock struct from a trait.

Parameters

static_references

Forces values stored in argument matchers to be 'static. This is used when the mock needs to satisfy 'static e.g. when downcasting the mocked trait to a concrete implementation using the Any trait. There is an example available on how to do this.

use mockiato::mockable;
use std::any::Any;

#[cfg_attr(test, mockable(static_references))]
pub trait Animal: Any {
    fn make_sound(&self);
}

name

Sets a custom name for the mock struct instead of the default.

use mockiato::mockable;

#[cfg_attr(test, mockable(name = "CuteAnimalMock"))]
trait Animal {
    fn make_sound(&self);
}