flutter-testing

Applies mockito-based test doubles with Riverpod provider overrides in Flutter tests.

4|Updated Jun 21, 2026
One-click install
npx skills add https://github.com/NEETROF/cymbra --skill flutter-testing-neetrof
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: flutter-testing
Source: https://github.com/NEETROF/cymbra/tree/main/.claude/skills/flutter-testing
Command: npx skills add https://github.com/NEETROF/cymbra --skill flutter-testing-neetrof

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires mockito, build_runner.

What problem does it solve? Flutter tests in the Cymbra music app need a consistent convention for test doubles. Without one, developers mix hand-written fakes and mocks inconsistently, making tests harder to maintain and review. ## Core Features & Use Cases - Mockito by default: Enforces @GenerateNiceMocks with build_runner to generate mocks for services, repositories, ports, and clients. - Riverpod injection: Mocks are injected via ProviderContainer or ProviderScope overrides, keeping the deps-as-providers pattern and banning constructor injection. - Documented exceptions: Defines the narrow cases where hand-written fakes are allowed, such as behavioural in-memory stores or trivial value stubs. - Use Case: When writing a notifier test for score uploads, generate a MockScoreUploadService, stub listMyScores with when/thenAnswer, override the provider, and verify deleteScore was called once. ## Quick Start Write a Flutter unit test for the score upload notifier using a mockito mock injected through a Riverpod provider override.

Frequently Asked Questions about flutter-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mock a service in a Flutter Riverpod test?▼

Annotate the test with @GenerateNiceMocks for the service, run build_runner to generate the mock class, then inject it with ProviderContainer overrides using overrideWithValue. Stub calls with when(...).thenAnswer(...) and assert interactions with verify(...).

Should I use mockito or hand-written fakes for Flutter tests?▼

Default to mockito with @GenerateNiceMocks for dependency doubles. Hand-written fakes are reserved for behavioural in-memory stores, trivial value stubs, or fakes shipped by production code, and each fake needs a one-line justification comment.

What is the difference between @GenerateNiceMocks and @GenerateMocks?▼

@GenerateNiceMocks returns sane default values for unstubbed calls, while @GenerateMocks throws MissingStubError. Prefer @GenerateNiceMocks unless a test specifically needs the strict behaviour of failing on unstubbed calls.

Why is my Flutter test failing with missing *.mocks.dart files?▼

Generated mock files are gitignored like *.g.dart files, so they do not exist on a fresh checkout. Run dart run build_runner build --delete-conflicting-outputs in apps/music before running analyze or test.

Can I use constructor injection for mocks in Flutter tests?▼

No, constructor injection is banned in this convention. Dependencies are Riverpod providers, so mocks must be injected through ProviderContainer or ProviderScope overrides, keeping the same injection pattern whether the double is a mock or a fake.