mockiato 0.6.3

A strict, yet friendly mocking library for Rust 2018
Documentation

Mockiato

Build Status Latest Version Documentation dependency status

A strict, yet friendly mocking library for Rust 2018

⚠️ This crate requires the nightly compiler

Quickstart

#[cfg(test)]
use mockiato::mockable;

#[cfg_attr(test, mockable)]
trait Greeter {
    fn greet(&self, name: &str) -> String;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn greet_the_world() {
        let mut greeter = GreeterMock::new();

        greeter
            .expect_greet(|arg| arg.partial_eq("world"))
            .times(1..2)
            .returns(String::from("Hello world"));

        assert_eq!("Hello world", greeter.greet("world"));
    }
}

Trait Bounds

Trait bounds are currently not supported meaning that the supertraits will not be implemented for mocks.

The following traits are always implemented for mocks:

Downcasting

An example of how to use downcasting with mockiato can be found in the downcasting example.

Contributing

Enable debug impls in codegen

cargo test --features mockiato-codegen/debug-impls