use std::fmt::Display; use ridicule::mock; trait Foo { fn bar(&self, num: u128) -> Baz; fn abc(&mut self, baz: Baz); } mock! { MockFoo {} impl Foo for MockFoo { fn bar(&self, num: u128) -> Baz; fn abc(&mut self, baz_baz: Baz); } } fn main() { let mut mock_foo = MockFoo::new(); mock_foo .expect_bar() .returning(|_me, num| { println!("bar was called with {num}"); "Hello".to_string() }) .times(3); mock_foo.expect_bar().returning(|_me, num| { println!("bar was called with {num}"); 128u8 }); assert_eq!(mock_foo.bar::(123), "Hello".to_string()); assert_eq!(mock_foo.bar::(123), "Hello".to_string()); assert_eq!(mock_foo.bar::(123), "Hello".to_string()); // Would panic // mock_foo.bar::(123); assert_eq!(mock_foo.bar::(456), 128); }