What problem does it solve?
Riverpod testing patterns reduce flakiness and increase confidence by isolating state per test, enabling provider overrides, and validating behavior without spinning up a full app.
Core Features & Use Cases
- Unit tests (no Flutter): Use ProviderContainer.test() to create a container for the test. Read provider values with container.read(provider) and observe changes with container.listen(provider, callback).
- Widget tests: Wrap the widget under test with ProviderScope and interact via tester.container() to inspect provider state.
- Mocking providers: Apply overrides to substitute real providers with test doubles, enabling deterministic scenarios.
- Awaiting async providers: Read provider.future and await completion to validate asynchronous values.
- Listening / spying: Use container.listen to capture sequences of values over time for assertions.
- Mocking Notifiers: Prefer replacing dependencies used by Notifiers with mocks rather than rewriting notifier logic.
Quick Start
Create a unit test for Riverpod providers using ProviderContainer and overrides to verify behavior in isolation.