A set of utility functions for mocktail apis.
First import mocktailx to your pubspec:
mocktailx: ^latest version here
Note that this library is a container for mocktail, so you don't need to import mocktail.
And don't forget to fix your imports:
import 'package:mocktailx/mocktailx.dart';
// Instead of doing:
when(repo.futureVoidFunction).thenAnswer((invocation) async {});
// You can just:
when(repo.futureVoidFunction).thenAnswerWithVoid();
// Instead of doing:
when(repo.futureIntFunction).thenAnswer((invocation) async => 10);
// You can just:
when(repo.futureIntFunction).thenAnswerWith(10);
// Instead of doing:
final List<Future<int> Function(Invocation)> answers = [
(_) async => 6,
(_) async => 7,
(_) async => 99,
];
when(() => repo.asyncInteger()).thenAnswer((invocation) => answers.removeAt(0)(invocation));
// You can just:
when(() => repo.asyncInteger()).thenAnswerInOrder([
(invocation) async => 6,
(_) async => 7,
(_) async => 99,
]);
// Instead of doing:
when(repo.streamValue).thenAnswer((invocation) => Stream.fromIterable([1,2,3,4,5]));
// You can just:
when(repo.streamValue).thenEmit([1,2,3,4,5]);
// Instead of doing:
when(repo.voidFunction).thenReturn(null);
// You can just:
when(repo.voidFunction).thenReturnWithVoid();
// Instead of doing:
when(() => repo.addOne(1)).thenReturn(6);
when(() => repo.addOne(2)).thenReturn(7);
when(() => repo.addOne(3)).thenReturn(99);
// You can just:
when(() => repo.addOne(any())).thenReturnInOrder([6, 7, 99]);
// Instead of doing:
final answers = [6, 7, 99];
when(() => repo.addOne(1)).thenAnswer((invocation) => answers.removeAt(0));
// You can just:
when(() => repo.addOne(1)).thenReturnInOrder([6, 7, 99]);