-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Mocktopus is very handy for mocking free functions. But when mocking structs, it requires a real copy of the struct to be instantiated. That's not always easy or possible in test environments. That's why most mocking libraries work in terms of traits instead. It would be great if Mocktopus could provide a macro that would instantiate a trait and mock all of its methods. Something like this:
#[mockable]
pub trait A {
fn foo(&self) -> u32;
}
mock!{AMock, A}The mock macro could expand to this:
#[derive(Default)]
pub struct AMock {}
#[mockable]
impl AMock {
fn foo(&self) -> u32 {
unimplemented!()
}
}Metadata
Metadata
Assignees
Labels
No labels