Dart Mockito — UnimplementedError, Fake.noSuchMethod
У меня есть этот тест:
test(
'Form is Edit, and value is different to form value, sets form type to Add, and sets hasFormTypeChanged to true',
() async {
manageVgnItmStore = MockManageVgnItmStore();
final formVm = MockManageVgnItmsFormStore();
when(formVm.hasFormTypeChanged).thenReturn(false);
when(manageVgnItmStore?.lastSelectedVgnItm).thenReturn(
const VgnItm.groceryItm(companyName: 'Cadbury', name: 'Chocolate'));
when(manageVgnItmStore?.stateNotifiersVm)
.thenReturn(ManageVgnItmsStateNotifiersStore(manageVgnItmStore!));
when(manageVgnItmStore?.formVm).thenReturn(formVm);
when(manageVgnItmStore?.formVm.hasFormTypeChanged).thenReturn(false);
when(manageVgnItmStore?.formType).thenReturn(const Edit(name: 'Edit'));
underTest = VgnItmFormEvents(manageVgnItmStore!);
underTest?.onNameChanged('fasdfsdfsdf', form!);
verify(underTest?.manageVgnItmStore.formType = const Add(name: 'Add'));
verify(underTest?.manageVgnItmStore.formVm.hasFormTypeChanged = true);
});
Последнийverify
вызов выдает ошибку:
Нереализованная ошибка: hasFormTypeChanged
пакет: test_api
Fake.noSuchMethodпакет: vepo/src/презентация/магазины/manage_vegan_items/form_store.dart19:8 _FakeManageVgnItmsFormStore_0.hasFormTypeChanged
Как видите, я устанавливал его несколько раз:
when(formVm.hasFormTypeChanged).thenReturn(false);
when(manageVgnItmStore?.formVm.hasFormTypeChanged).thenReturn(false);
Почему возникает эта ошибка?