Warning
This post was published 60 days ago. The information described in this article may have changed.
I'm hoping to make a stateful mock object by using mockall to mock a struct with fields I control similar to the following:
struct Counter {
pub count: u8,
}
mock! {
pub Counter {}
}
let test = MockCounter::new();
dbg!("Count is {:?}", test.count)
but this fails to compile, complaining that there is no field count on type MockCounter. Is there any way to access custom fields on a mock object or otherwise track custom state? Only other option that comes to mind is static variables, but I would prefer to stay in the scope of mock object definitions for cleanliness and simplicity if possible.
2 posts - 2 participants
🏷️ rust_feed