I have following function
Future<T> execute<T>(Future<T> Function(ApiService apiService) getFromRemote,
{Future<void> Function(T data) cacheData, Future<T> Function() getFromCache}) {
}
And I want to verify that cacheData function is called in following test
CacheDataFunction mockCacheDataFunction;
setUpAll(() {
mockCacheDataFunction = CacheDataFunction();
});
test('caches value provided in future', () async {
await repositoryRequestExecutor.execute<int>(
(_) => Future.value(testValue),
cacheData: (data) => mockCacheDataFunction<int>(data),
getFromCache: () => Future.value(testValueFromCache),
);
verify(mockCacheDataFunction<int>(testValue));
});
So I made such a mock
class CacheDataFunction extends Mock{
Future<void> call<T>(T data) => Future.value();
}
But it throws Used on a non-mockito object error. How can I achieve it?