Closed Houndie closed 1 year ago
Easy. You need to use #[double]
in main()
as well as in mod a
. Or, just use it at the top level in main.rs
, and use super::Thing
in mod a
.
Okay! I thought it might be something like that. Not necessarily a fan of the solutions, but it's good to know how it's supposed to be done. I might just mock out with traits instead. Thanks!
Question on how to use
mockall_double
for struct swapping. I'm new to rust so there may be an obvious solution I'm seeing here, but how to fix this problem is not clear to me!I've adapted the struct swapping example in the documentation into an actual program:
When building this code, everything works as expected. However, when running
cargo test
I get the following error:It's pretty obvious what is happening,
mockall_double
is struct swapping as expected, however, the main function is still passing a the non-mock to the function, which causes an error.My question is....is there a way around this while still using struct swapping? I like the idea behind it for testing but this is kind of a blocker