bloc_test 1.0.0
bloc_test: ^1.0.0 copied to clipboard
A testing library which makes it easy to test blocs. Built to be used with the bloc state management package.

A Dart package that makes testing blocs easy. Built to work with bloc and mockito.
Create a Mock Bloc #
import 'package:bloc_test/bloc_test.dart';
import 'package:mockito/mockito.dart';
class MockCounterBloc extends Mock implements CounterBloc {}
Stub the Bloc Stream #
// Create a mock instance
final counterBloc = MockCounterBloc();
// Stub the bloc `Stream`
whenListen(counterBloc, Stream.fromIterable([0, 1, 2, 3]));
// Assert that the bloc emits the stubbed `Stream`.
expectLater(counterBloc, emitsInOrder(<int>[0, 1, 2, 3])))
Dart Versions #
- Dart 2: >= 2.0.0