Closed Nikzed closed 10 months ago
Is this a right way to declare mock classes?
late final MockDoSomethingUseCase _doSomethingUseCase;
setUp(() {
_doSomethingUseCase= MockDoSomethingUseCase();
});
Found in readme about stubbing
The when, thenReturn, thenAnswer, and thenThrow APIs provide a stubbing mechanism to override this behavior. Once stubbed, the method will always return stubbed value regardless of how many times it is called. If a method invocation matches multiple stubs, the one which was declared last will be used. It is worth noting that stubbing and verifying only works on methods of a mocked class; in this case, an instance of MockCat must be used, not an instance of Cat.
Thanks to this kind guy issue https://github.com/dart-lang/mockito/issues/364
but I do have the next problem with any()
Are you certain you are using this mockito package? We do not have a function called any()
. There is a top-level property called any
.
Anyway, it looks like that's an instance of "you must declare your mocks to have static mock type", since we are doing overrides. I think we can just close it.
Anyway, it looks like that's an instance of "you must declare your mocks to have static mock type", since we are doing overrides. I think we can just close it.
Yes, this is definitely was in generated file .mock
I have a use case with not Null incoming parameter.
and I do want to test it the next way:
but I do have the next problem with
any()
Is there any way to mock this behavior?