Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

flutter - Mockito and ScopedModel

I'm trying to fix a test since I have implemented ScopedModelDescendant to get data to fill up my page with information for the user.

The issue I'm facing is that it seems I can not mock ScopedModel with mockito. Somehow is asking me to specify some properties which does not occur with other classes I have been mocking so far.

this is my build for the widget

This is how my app is being configured

enter image description here

So far so good, my app is working properly and I can invoke ScopedModelDescendant anywhere without injecting anything in my widgets. But when running my test I'm getting this error

enter image description here

And this is how I'm configuring my test

enter image description here

I know I should be doinng something like this

class MockScopedModel extends Mock implements ScopedModel<MockMainModel>{}

But if I do that in order to mock sopedModel I get this error/warning

enter image description here

Does anyone know how to mock the scopedModel properly? Am I missing something here?

question from:https://stackoverflow.com/questions/66051716/mockito-and-scopedmodel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ok, so issue was I was not specifying the type for the scopeModel class in my test.

Github ticket

It is strange that in my code was not required to specify the type for my ScopedModel but in my test it did. Anyways I hope this helps anyone who might encounter this issue while testing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...