'Mockito can not mock Hive box with annotation

I try to do a unit test with logic which use Hive box in Flutter

I follow guide of UT test flutter and mockito
https://docs.flutter.dev/cookbook/testing/unit/mocking
https://pub.dev/packages/mockito

After run: flutter run build_runner build The mock class is generated

I use mockClass such as:
enter image description here

But the code doesnot run well. The box is not oppened error still appear. enter image description here


How can I mock Hive box correctly?
Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source