flutter-testing

Featured

Use when testing Flutter code - unit tests for logic, widget tests for UI behavior, golden tests for appearance, test-first

Testing & QA 91 stars 13 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 89/100

Stars 20%
65
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Flutter Testing ## Overview Test-first in Flutter (see tdd-workflow). Three layers, each for a different question: does the logic work, does the widget behave, does it look right. **Core principle:** Most tests are fast unit + widget tests. Golden tests guard appearance; integration tests guard whole flows — use them sparingly. ## Test layers | Layer | Question | Tool | |-------|----------|------| | Unit | Does the controller/logic compute correctly? | `flutter_test`, mock the repository | | Widget | Does the widget render state and respond to taps? | `testWidgets` + `pumpWidget` + finders | | Golden | Does it match the approved pixels? | `matchesGoldenFile` | | Integration | Does the whole flow work on a device? | `integration_test` | ## Widget test example ```dart testWidgets('shows error view and retries', (tester) async { final controller = FakeTaskController()..emitError('boom'); await tester.pumpWidget(wrap(TaskListScreen(controller: controller))); await tester.pump(); expect(find.text('boom'), findsOneWidget); await tester.tap(find.byType(RetryButton)); await tester.pump(); expect(controller.loadCalled, isTrue); // intent reached the controller }); ``` ## Rules - **Unit-test controllers/logic without pumping a widget** — that's the payoff of keeping logic out of widgets (see flutter-state-management). - **Widget tests assert observable behavior** (text visible, tap triggers intent), not internal structure. - **Mock the repository/ports**, no...

Details

Author
makifbaysal
Repository
makifbaysal/tasktrooper
Created
1 weeks ago
Last Updated
today
Language
Go
License
Apache-2.0

Similar Skills

Semantically similar based on skill content — not just same category