Reputation: 645
Hello im writing a test using mockito but when i try to use the example in mockito documentation it throws an error for me,
Im asking what is the right syntax for the function inside the thenAsnswer?
ERROR: The argument type 'Future Function(Invocation)' can't be assigned to the parameter type 'Future Function() Function(Invocation)'
test(
"GIVEN success call WHEN login called THEN return User",
() async {
//arrange
when(
() => service.login(credentials: credential),
).thenAnswer(
(_) async => Future.value(user),
);
//act
final futureUser = await service.login(
credentials: credential,
);
//assert
expect( futureUser, user);
},
);
Upvotes: 0
Views: 472
Reputation: 682
Just replace
when(
() => service.login(credentials: credential),
).thenAnswer(
(_) async => Future.value(user),
);
with
when(
service.login(credentials: credential),
).thenAnswer(
(_) async => Future.value(user),
);
Happy coding :)
Upvotes: 2