A powerful mock object library for Rust.
https://docs.rs/mockall/latest/mockall/
Mockall provides tools to create mock versions of almost any trait or struct. They can be used in unit tests as a stand-in for the real object. Usage
There are two ways to use Mockall. The easiest is to use #[automock]. It can mock most traits, or structs that only have a single impl block. For things it can’t handle, there is mock!.
Whichever method is used, the basic idea is the same.
Create a mock struct. It’s name will be the same as the original, with “Mock” prepended.
In your test, instantiate the mock struct with its new or default method.
Set expectations on the mock struct. Each expectation can have required argument matchers, a required call count, and a required position in a Sequence. Each expectation must also have a return value.
Supply the mock object to the code that you’re testing. It will return the preprogrammed return values supplied in the previous step. Any accesses contrary to your expectations will cause a panic.