Questions tagged [mockito-dart]
9 questions
9
votes
2 answers
Is there a way to let mockito generate mocks for integration tests in a Flutter project
Mockito generates mocks for all classes listet within the @GenerateMocks annotatio. It does so for tests in the test folder but it doesn't for tests in the integration_test folder. How do I change that?

HerrJohr
- 419
- 3
- 8
2
votes
0 answers
Mock object not recognized as Mockito in Flutter widget test using GetIt
I am writing a widget test that verifies a logout button. When the logout function is triggered via a user button tap, some items in FlutterSecureStorage are cleared. I want to verify that a method was called in our Preferences class which is a…

Pheepster
- 6,045
- 6
- 41
- 75
1
vote
0 answers
Dart Mockito - UnimplementedError, Fake.noSuchMethod
I've got this test:
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 =…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287
1
vote
0 answers
MissingStubError when add Future method in constructor dart
i tried to make a similar footsteps some youtube guideline (bloc) and run perfectly in production code. The bloc guideline shows to input an asynchonous function in constructor, but when i create a simple success test occurs the error…
1
vote
1 answer
Testing exceptions in Dart
When writing tests around code that will throw an exception, how can Dart/Mockito(or anything else) avoid throwing a real exception?
For example, these tests should both pass and detect the thrown exception - but Dart throws a real exception in the…

Oliver H
- 133
- 8
1
vote
0 answers
How to verify that function passed as argument called in dart unit tests
I have following function
Future execute(Future Function(ApiService apiService) getFromRemote,
{Future Function(T data) cacheData, Future Function() getFromCache}) {
}
And I want to verify that cacheData function is called…

Ilya Maximencko
- 411
- 2
- 15
0
votes
1 answer
No matching calls with Mockito verify despite call matches
I have a provider named SqliteFavoriteProvider and it has a method named add, it is as shown:
@override
Future add({
required int startStationId,
required int endStationId,
int? dayId,
}) async {
// `_database` here will…

Eray Erdin
- 2,633
- 1
- 32
- 66
0
votes
1 answer
How do I stub callbacks of a method?
I am using Firebase Phone Auth in my Flutter project and want to test my auth class. I know how to use when() and .thenAnswer() from Mockito with typical Futures.
I want to test my authentication method, in particular, verificationFailed and…

Tumist
- 119
- 3
- 11
0
votes
1 answer
What is difference between argThat and captureThat matchers in dart mockito?
I've tried to find the difference here https://pub.dev/packages/mockito and using documentation to this matchers but didn't get it. Could someone provide example where I supposed to use captureThat rather than argThat?

Ilya Maximencko
- 411
- 2
- 15