how can i make mock of AutoDisposeAsyncNotifier ? #3737
-
/// notifier
@Riverpod(keepAlive: true)
class TempNotifier extends _$TempNotifier {
@override
FutureOr<SomeState> build() {
...
return SomeState.initial() ;
} i tried @GenerateMocks([TempNotifier])
@GenerateNiceMocks([MockSpec<TempNotifier>()])
class MockTempNotifier extends AutoDisposeAsyncNotifier<SomeState>
with Mock
implements TempNotifier {}
...
final mockTempNotifier = MockTempNotifier();
final container = ProviderContainer( overrides: [tempNotifierProvider.overrideWith(()=>mockTempNotifier)] )
but i can't solve this problem.... error message is @GenerateMocks([TempNotifier])
@GenerateNiceMocks([MockSpec<TempNotifier>()])
/// noSuchMethodError: Class 'MockTempNotifier' has no instance method '_setElement' class MockTempNotifier extends AutoDisposeAsyncNotifier<SomeState>
with Mock
implements TempNotifier {}
/// The implementation of '_element' in the non-abstract class 'MockTempNotifier' does not conform to its interface. Has anyone experienced the same problem? |
Beta Was this translation helpful? Give feedback.
Answered by
hisaichi5518
Sep 13, 2024
Replies: 1 comment
-
The following documentation is helpful:
https://riverpod.dev/docs/essentials/testing#mocking-notifiers |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
BowonLee
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following documentation is helpful:
https://riverpod.dev/docs/essentials/testing#mocking-notifiers