faux
A struct mocking library for stable Rust.
This library was inspired by mocktopus, a mocking library for nightly rust that lets you mock any function. Unlike mocktopus, faux deliberately only allows for mocking public methods in structs rather than any function.
Faux is in its early alpha stages and there are no guarantees of API stability
use crate UserClient;
// A sample #[test] for Service that mocks the client::UserClient
Goal
Faux aims at providing the user with the power to create mocks out of their structs for testing without the need to change their production code for testing-purposes only. In particular, faux avoids forcing the user to create traits to define every type they want mocked, and then pollute their function signatures with either generics or trait object.
It is the belief of the author that if a trait is only ever implemented by a single object, then that trait is an undue burden. Having to change your function/struct signatures to support generics in production code when only tests would ever use a different type should be an anti-pattern.