Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/CodeSandwich/Mocktopus

Mocking framework for Rust
https://github.com/CodeSandwich/Mocktopus

mock mocking mocktopus rust rust-library test testing testing-tools unit-testing

Last synced: about 2 months ago
JSON representation

Mocking framework for Rust

Awesome Lists containing this project

README

        

[![Crates.io](https://img.shields.io/crates/d/mocktopus.svg)](https://crates.io/crates/mocktopus)
[![Docs.rs](https://docs.rs/mocktopus/badge.svg)](https://docs.rs/crate/mocktopus)
[![Build Status](https://travis-ci.org/CodeSandwich/Mocktopus.svg?branch=master)](https://travis-ci.org/CodeSandwich/Mocktopus)


logo

Mocking framework for Rust (currently only nightly). See [documentation](https://docs.rs/mocktopus/) for more.

```rust
#[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());
}
```