I'm working on a Rust CLI application and I'd like to mock Command so that I can make assertions about the calls my program is making to it. For example, command instance A receives .args(true, 1) and .output().unwrap() only once.
The conventional wisdom seems to be to use mockall, traits/structs and dependency injection to achieve this. However, this seems to very quickly become a matryoshka doll of "factories" and function arguments (i.e. dependency injection) which exist only to facilitate this test scenario. Coming from a Ruby/Python background, where I'd use something like MagicMock or monkeypatching to dynamically sub in my mock, this feels very heavy handed and convoluted. Without using "nightly" features, it also seems like I'm required to litter my application with test-specific imports and pragmas (e.g. #[automock]) because I can't create test-specific trait implementations within the test module.
So, is using this factory pattern and dependency injection and the related program modifications really the best way to go? Are there libraries other than mockall which address this concern using a "lighter touch" or ways to achieve this behavior using only the stdlib?