如何使用网络相对存储仪进行单位测试集团?
我创建一个bloc调用身份验证
。此集团发出两个状态调用自动启动
和 基于
AuthenticationRepository
,将其依赖性注入BLOC。
然后,我想为单位测试创建模拟的ocerauthenticationRepository
,但是我得到了两个不同的状态,因此我必须创建两个不同版本的存储库,例如oige> oigaautenticatiCatiCatiCatiCateCationAuthenticationRepository
和mockunAuthententicateTicatiCatiCatiCatiCatiCateCationRicationRepository
代码>测试这两种情况。
但是,也许在存储库上还有另一个集合5或6个州基础,然后我必须为其创建5至6个模拟的存储库。这听起来并不是很大的错误,因为一个集团不会生长无限。但是我仍在寻找更好的方法来解决这个问题。有人有更好的主意吗?
I create a bloc call Authentication
. This bloc emit two state call Autenticated
and UnAuthenticated
base on AuthenticationRepository
which dependency injected into bloc.
Then I tring to create a mocked MockAuthenticationRepository
for unit test but I got two different state so I have to create two different version of repository like MockAutenticatedAuthenticationRepository
and MockUnAuthenticatedAuthenticationRepository
to test these two case.
But maybe there is a another bloc emit 5 or 6 state base on repository then i have to create 5 to 6 mocked repository for it. This sound not terribly wrong because one bloc shondn't growing unlimit. But I still looking for better way to solve this. Anyone got better idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用“ https://pub.dev/packages/mocktail”“ rel =” nofollow noreferrer“> https://pub.dev/packages/mocktail )存储库的正确行为。
使用软件包bloc_test( https://pub.dev/packages/bloc_test )实现集体单元测试。
您必须调整方法调用,依此类推,因为我没有示例代码。但是我认为这应该有助于您解决问题。
you can use the package mocktail (https://pub.dev/packages/mocktail) to set up the correct behavior of the repository.
It´s also a good idea to use the package bloc_test (https://pub.dev/packages/bloc_test) to implement bloc unit tests.
You have to adapt the method calls and so on, because i don´t have your example code. But i think that should help you solving your problem.