flutter-testing
Installation
SKILL.md
Flutter Testing Standards
Priority: P0 (CRITICAL)
Core Rules
- Test Pyramid: Unit > Widget > Integration.
- Naming:
should <behavior> when <condition>. - AAA: Arrange, Act, Assert in all tests.
- Shared Mocks:
test/shared/only — no local mocks. - File Placement:
_integration_test.dartONLY inintegration_test/. - Robot-First: ALL UI assertions/interactions via Robot pattern (e.g.,
CheckoutRobot) — never rawfind.*/expect()in test body.
Widget Testing & Mocking
- Setup: Use
TestWrapper.init()insetUpAllandtester.pumpLocalizedWidget(...). - Mocking: Use GetIt registration of Mock BLoCs in
setUpAllif created internally. Use blocTest for BLoC logic and whenListen for state transitions. - Stubbing: Always stub bloc.state and bloc.stream in
setUp. Prohibitany()/anyNamed(). - Async: Use settle: false for loading or stream states to verify mid-process transitions.