Mockito不能用注释模拟蜂巢盒

发布于 2025-01-21 13:11:05 字数 934 浏览 1 评论 0原文

我尝试使用逻辑进行 单位测试 ,它在 hive box /strong>

我遵循UT测试的指南和摩擦图
https://docs.flutter.dev/cookbook/testing/testing/testing/unit/unit/mocking/unit/mocking
https://pub.dev/packages/mockito

run /代码> 模拟类是生成

我使用的模拟班级,例如:

但是代码不运行良好。 盒子没有反对错误。


我如何正确模拟蜂巢盒?
先感谢您。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文