state_notifier_test
0.0.10, released 4 years ago by that-dev.me
A testing utility library for StateNotifier and Riverpod
What it does
Provides the stateNotifierTest function to easily test StateNotifier state emissions, actions, seeding, and verification, ported from bloc_test.
AI-written summary of version 0.0.10, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using state_notifier, riverpod, or flutter_riverpod in your project
- You want a structured, readable syntax for testing state changes in StateNotifiers
Skip it when
- You are not using StateNotifier or Riverpod for state management
- You prefer standard Flutter test assertions without helper wrappers
Strengths
- Clear, declarative syntax for testing emitted states
- Supports seeding initial states, skipping emissions, and custom verifications
Weaknesses
- Relies on a third-party port of bloc_test which may lag behind official bloc_test updates
- Limited to StateNotifier architectures
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Add state_notifier_test to dev_dependencies in pubspec.yaml.
stateNotifierTest(
'CounterNotifier emits [9,10] when seeded with 9',
build: () => CounterNotifier(),
seed: () => [9],
actions: (stateNotifier) => stateNotifier.increment(),
expect: () => [9,10],
);Alternatives
Packages that do the same job and could replace state_notifier_test.
- bloc_test
A testing library that makes it easy to test blocs and cubits.
82Compare - riverpod_test
A testing library for easily testing Riverpod providers.
52Compare - elementary_test
Testing library for apps built with the Elementary architecture.
68Compare - flutter_svg_test
A testing library for finding and verifying flutter_svg images in widget tests.
66Compare
Works with
Packages commonly used together with state_notifier_test: ones it builds on, ones built on it, and its own family.
- teststate_notifier_test depends on itA full featured library for writing and running Dart tests across platforms.
- state_notifierstate_notifier_test depends on itValueNotifier outside Flutter for managing state in an immutable manner.
- mockitostate_notifier_test depends on itA mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing.
- diff_match_patchstate_notifier_test depends on itDart library implementing diff, match and patch algorithms for plain text.