Hi
It is there a way to create a mock of a bloc for unit tests? I tried to create a mock but its current state is null.
Thank you in advance
Hi @jkyon 馃憢
Thanks for opening an issue!
Regarding your question you can create a mock bloc using mockito like so:
class MockBlocA extends Mock implements BlocA {}
you can then create an instance like so
void main() {
group('Tests', () {
BlocA blocA;
setUp(() {
blocA = MockBlocA();
});
});
}
Then you can mock the currentState in your tests like so:
when(blocA.currentState).thenAnswer((_) => BlocAState());
Hope that helps and great question! 馃憤
thank you!
It works perfect!
Most helpful comment
thank you!
It works perfect!