I am new on Flutter. I have started to writing tests. I saw
mocktail as the most used testing libraries. I couldn’t find any question/articles that explains differences between them. If there is a experienced developers -who used both of them- can you explain differences/advantages/disadvantages of them? Which one should I prefer?
Thanks in advance!
1. Assuming that you are new with Flutter, it would be probably easier for you to utilize the mocktail package.
The main "inconvenience" with the mockito package is that you need to generate the mocks running flutter pub run build_runner build, define meta-annotations like @GenerateMocks, and imports like xxx.mocks.dart, and an extra build_runner dev dependency at your pubspec.yaml.
The mocktail package simplifies mocking: you just need to extend the Mock class. That’s it. Without code-generating, annotations, "magic" xxx.mocks.dart imports.
2. Also, you have to keep in mind that the mocktail package is very new and has a stable history of just 10 months. The mockito package is a proven by time and developers library that has almost 8 years of history of stable releases: the library is well-known and is widespread among the Flutter and Dart community.
With the experience, you will better understand which library better fits your projects’ needs.
PS: you can take a look at the code snippets of both packages.
The mocktail snippet screenshot:
The mockito snippet screenshot
Answered By – Max
Answer Checked By – Mary Flores (FlutterFixes Volunteer)