asomers / mockall

A powerful mock object library for Rust
Apache License 2.0
1.5k stars 62 forks source link

Change the recommendation for static methods #528

Closed asomers closed 10 months ago

asomers commented 10 months ago

Using a static method in two or more test cases requires synchronization, such as with a Mutex. Previously we recommended adding a let _m = SOME_MTX.lock().unwrap() to the top of each such test case. But if one test case should fail, then the others will fail too due to a poisoned mutex. It turns out that the .unwrap() is completely unnecessary; a poisoned Mutex still provides the necessary synchronization. So simply remove all of the unwraps.