-
I would like to disable automocking for nested modules. The rationale is that I have a module that has public and private functions. I would like to test the private functions (and yes, I know there are religious wars about unit testing private functions, I fall into the camp of wanting to do that). Ideally, I'd like to be able to do something like this: #[cfg(test)]
use mockall::automock;
// Somehow annotate the following that I do not want to automock embedded modules
#[cfg_attr(test, automock)]
pub mod my_module {
pub fn public_func() {}
fn private_func() {}
#[cfg(test)]
mod tests {
// tests both public and private modules
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
asomers
Nov 3, 2024
Replies: 1 comment
-
That's an interesting request. Yes, it could be made to work. In the meantime, as a workaround you'll have to move the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
apicize
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's an interesting request. Yes, it could be made to work. In the meantime, as a workaround you'll have to move the
tests
module out of the automocked module.