Rust Mock Shootout!


#1

Rust has several different mocking libraries. None is clearly superior to all of the others. This project compares their feature sets, using an apples-to-apples approach. Each of several dozen features is implemented with multiple mocking libraries, if possible. The test results then show which features work with which library.

Do you need both static methods and methods that return references with non-'static lifetimes? Then you should use Mock_Derive. Or perhaps you like to derive your mocks and you need to validate call sequences? Then you should use Mockers.

Check our the handy table to find the mocking library that’s right for you.


#2

That’s a really nice comparison. I especially like that you came up with a comprehensive feature test suite.


#3

This is incredibly thorough! Thanks a lot for creating this resource.

A note on a potentially improvement: it’d be very helpful for colorblind (and even blind) users if you put some “YES” / “NO” text in the big feature comparison table. Especially given that you chose red and green :slight_smile:


#4

Good point. Fixed!


#5

Thanks for this, really nice one. Just searching what mocking lib to use.


#6

FYI, I’m continuously updating the shootout. If you want to see new additions, you should subscribe to the Github repo. I won’t post every update to the forum. Today’s update: not a single library is capable of mocking a Send trait.


#7

I dropped Mock_Derive off the list, because it’s fallen behind on maintenance. It no longer compiles with recent nightly toolchains. Also, double now implements Send.


#8

I actually have a branch running on nightly for my project that has been updated to the latest syn/quote and brought up-to-date so it compiles, plus added some features I needed. It’s located here https://github.com/carlosdp/mock_derive . I’ve been thinking of contacting the maintainer to see if I can perhaps come on as a maintainer myself and work on it, since I intend to use it for my stuff. It’s super convenient.