That is one of my takeways as a relatively new Rust developer from a recent endeavor during the winter break. With finally enough time to work on one of my currently most-used projects **picoKontroller** --- a multi-use MIDI controller software --- I dared to tackle one of this project's biggest shortcomings: Testing.
Since the core functionality of this project depends on the presence of a MIDI device, as well as PulseAudio/Pipewire, I wanted to attempt to mock these subsystems in order to increase overall testability. In this context I decided to apply dependency injection with the goal to transform this system into a thoroughly testable and well structured project.
After some research on the most well known dependency injection and mockinng libraries for Rust I decided on [Shaku](https://github.com/AzureMarker/shaku) and [Mockall](https://github.com/asomers/mockall), being each the most renowned project in their respective category.
This was inspired by a [Japanese post on Qiita](https://qiita.com/no_job_swan/items/703f1f08f6a998aea183) by user _no\_job\_swan_, introducing [tauri](https://github.com/tauri-apps/tauri) --- an alternative to electron --- to developers coming from the JavaScript world who don't know Rust.
## First Approach
tried to use traits as polymorphy -> upcast not possible
don't use boxed traits [blog](https://bennett.dev/dont-use-boxed-trait-objects-for-struct-internals/)