-
Given #[cfg_attr(test, automock)]
pub trait ICmdRunner {
fn run(cmd: Cmd, verbosity: Verbosity) -> Result<()>;
} (note the lack of
[test]
// ...
let cmd_runner = {
let tmp_mock = MockICmdRunner::default();
tmp_mock
.expect_run() // in case `automock` made an `expect_run` method
.times(1)
.with(eq(expected_res), eq(verbosity))
.returning(|_, _| Ok(()));
tmp_mock
};
// ... and [test]
// ...
MockICmdRunner::expect_run().times(1).with(eq(expected_res), eq(verbosity)).returning(|_, _| Ok(())); // in case `automock` made a static `expect_run()`
// ... without success.
|
Beta Was this translation helpful? Give feedback.
Answered by
asomers
Jun 22, 2023
Replies: 1 comment 1 reply
-
See the example at https://docs.rs/mockall/latest/mockall/#static-methods . Because there's no receiver, the syntax is a little bit different. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
U007D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the example at https://docs.rs/mockall/latest/mockall/#static-methods . Because there's no receiver, the syntax is a little bit different.