Open 5hirish opened 9 months ago
On trying to mock a Riverpod StateNotifierProvider of (AutoDispose)FamilyNotifier -
@Riverpod(keepAlive: true) class ProjectDirectoryPath extends _$ProjectDirectoryPath { @override String? build() { return null; } }
Mockito code generation fails to generate the appropriate mock for it -
@GenerateNiceMocks([ MockSpec<ProjectDirectoryPath>(), ]) void main() { container = ProviderContainer(overrides: [ projectDirectoryPathProvider .overrideWith(() => mockProjectDirectoryPath), ]); }
Error -
NoSuchMethodError: Class 'MockProjectDirectoryPath' has no instance method '_setElement'. Receiver: Instance of 'MockProjectDirectoryPath' Tried calling: _setElement(Instance of 'NotifierProviderElement<ProjectDirectoryPath, String?>')
How can I generate the appropriate mock using the code generation of mockito? This issue is explored here in depth - https://github.com/rrousselGit/riverpod/issues/2373
We are seeing the same issue, will add more information. @5hirish did you find a workaround?
On trying to mock a Riverpod StateNotifierProvider of (AutoDispose)FamilyNotifier -
Mockito code generation fails to generate the appropriate mock for it -
Error -
How can I generate the appropriate mock using the code generation of mockito? This issue is explored here in depth - https://github.com/rrousselGit/riverpod/issues/2373