???
Most test scenarios map directly ? ProviderContainer APIs: read, invalidate, refresh, listen, ? overrides per provider instance.
Test Strategy
Split tests into pure container tests ? widget integration tests.
Pure Dart
Use ProviderContainer directly ? read/invalidate/refresh assertions
Overrides
Override per provider instance ?? overrideWith / overrideWithValue
Widget tests
Inject external container ? dispose it explicitly
Tip
ProviderContainer.listen은 fireImmediately: true가 지정되지 않으면 초기 값을 내보내지 않습니다.
Test Command ? ?????
Run full suite ? verify no pending timer leaks ?? autoDispose scenarios.
Command
Checklist
- Dispose externally injected ProviderContainer in tearDown.
- Use fireImmediately: true when your listener assertions need initial state.
- For autoDispose tests, advance fake time beyond autoDisposeDelay.
??: per-argument override
family-like ????? are overridden per instance created ?? your factory function.
class ProductById extends Provider<Product> {
ProductById(this.id) : super.args((id,));
final String id;
@override
Product build(ref) {
final repo = ref.watch(productRepoProvider);
return repo.fetch(id);
}
}
final container = ProviderContainer(
overrides: [
productByIdProvider('a').overrideWithValue(const Product(id: 'a', name: 'stub')),
],
);
// assert and cleanup
container.dispose();
This pattern mirrors the README ? upstream tests ?? miniriverpod repository.
위젯 테스트는 외부 컨테이너를 정리하기 전에 위젯을 언마운트해야 합니다.
Use fake_async ? validate autoDispose delays ? keepAlive behavior.
?? ??
API Reference
Open quick signatures ? ProviderContainer, Ref, AsyncValue, ? mutation APIs.
Open API Reference