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 thebloc
emits theexpect
ed states (in order) afteract
is executed. blocTest also handles ensuring that no additional states are emitted by closing thebloc
stream before evaluating theexpect
ation. -
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
listen
method on abloc
. Use whenListen if you want to return a cannedStream
of states for abloc
instance.