use mockem::{mock, MockCall}; struct Foo; trait Bar { fn bar(&self) -> String; } #[mock] impl Bar for Foo { fn bar(&self) -> String { format!("bar") } } fn baz() -> String { format!("Hello, {}!", ::bar(&Foo)) } #[test] fn test_trait() { ::bar.mock_once(|_| "mockem".to_owned()); assert_eq!(&baz(), "Hello, mockem!"); }