How to mock void parameter in use case

37 Views Asked by At

I do have the next Use Case

class GetLessonsUseCase extends UseCase<List<LessonEntity>, void> {
  final LessonsRepository _repository;

  GetLessonsUseCase(this._repository);

  @override
  Future<List<LessonEntity>> call({void params}) async {
    return _repository.getLessons();
  }
}

and the problem is that mockito generates the next code with error

// A class which mocks [GetLessonsUseCase].
///
/// See the documentation for Mockito's code generation for more information.
class MockGetLessonsUseCase extends _i1.Mock implements _i9.GetLessonsUseCase {
  @override
  _i3.Future<List<_i4.LessonEntity>> call({void params}) => (super.noSuchMethod(
        Invocation.method(
          #call,
          [],
          {#params: params},
        ),
        returnValue: Future<List<_i4.LessonEntity>>.value(<_i4.LessonEntity>[]),
      ) as _i3.Future<List<_i4.LessonEntity>>);
}

generated error

I tried to declare it with returnNullOrMissing, but still not working

@GenerateMocks([
  LessonsRepository,
  // GetLessonsUseCase,
  SetDrawerBadgesUseCase,
  GetYoutubeIconUseCase,
], customMocks: [
  MockSpec<GetLessonsUseCase>(returnNullOnMissingStub: true),
])
0

There are 0 best solutions below