bloc_test library
A testing library which makes it easy to test blocs.
Get started at bloclibrary.dev π
Classes
Functions
-
blocTest<
B extends BlocBase< (State> , State>String description, {required B build(), FutureOr< void> setUp()?, State seed()?, dynamic act(B bloc)?, Duration? wait, int skip = 0, dynamic expect()?, dynamic verify(B bloc)?, dynamic errors()?, FutureOr<void> tearDown()?, dynamic tags}) β void -
Creates a new
bloc-specific test case with the givendescription. blocTest will handle asserting that theblocemits theexpected states (in order) afteractis executed. blocTest also handles ensuring that no additional states are emitted by closing theblocstream before evaluating theexpectation. -
testBloc<
B extends BlocBase< (State> , State>{required B build(), FutureOr< void> setUp()?, State seed()?, dynamic act(B bloc)?, Duration? wait, int skip = 0, dynamic expect()?, dynamic verify(B bloc)?, dynamic errors()?, FutureOr<void> tearDown()?}) β Future<void> - Internal blocTest runner which is only visible for testing. This should never be used directly -- please use blocTest instead.
-
whenListen<
State> (BlocBase< State> bloc, Stream<State> stream, {State? initialState}) β void -
Creates a stub response for the
listenmethod on abloc. Use whenListen if you want to return a cannedStreamof states for ablocinstance.