Awesome Open Source
Awesome Open Source
Sponsorship

Crates.io Docs.rs Build Status

logo

Mocking framework for Rust (currently only nightly). See documentation for more.

#[mockable]
mod hello_world {
    pub fn world() -> &'static str {
        "world"
    }

    pub fn hello_world() -> String {
        format!("Hello {}!", world())
    }
}

#[test]
fn mock_test() {
    hello_world::world.mock_safe(|| MockResult::Return("mocking"));

    assert_eq!("Hello mocking!", hello_world::hello_world());
}

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
rust (3,985
testing (881
test (190
testing-tools (188
unit-testing (178
mock (164
mocking (97
rust-library (56

Find Open Source By Browsing 7,000 Topics Across 59 Categories