Closed RoloEdits closed 1 year ago
This is a problem with your editor, not Mockall. Most likely the editor expands the code in production configuration, not test configuration. What happens when you build?
Ok, I managed to get it working now. Seems there was an issue with using ::new()
and switching to ::default()
gave me a Mock object. I guess its a name conflict, already having a ::new()
function on the trait. If this is the case I think it should be in some kind of documentation. Though what happens if you also have a default implementation? And both function names are taken?
The confounding issue was the fact that the Rust IntelliJ plugin doesn't seem to have any hints or highlighting for the object. Opening in VS Code with rust-analyzer shows the correct hints and highlighting.
In fact it is already mentioned in the documentation. https://docs.rs/mockall/latest/mockall/#static-methods . And it isn't likely to be a problem if you already have a default
method, because who would ever use that name for a method outside of the Default
trait? And even if they do, you'll still be able to do <MyMock as Default>::default()
.
Trying to figure out why a
Mock
prefixed version of the trait isn't showing up as existing. The example I based off of was the README. I'm sure I'm missing something obvious, but can't seem to find out what.