flutter-testing
Comprehensive guidance for unit, widget, and integration testing across Flutter applications.
- Covers three test types with trade-off analysis: unit tests for isolated logic (fast, low maintenance), widget tests for UI components (higher confidence, more dependencies), and integration tests for end-to-end flows (highest confidence, slowest execution)
- Includes practical examples for all three test categories, from basic Counter tests to complex user flows and performance profiling
- Provides mocking strategies for plugin interactions, platform channel handling, and external dependencies to keep tests reliable and fast
- Addresses common testing errors (RenderFlex overflow, unbounded viewport, setState during build) with concrete solutions and prevention patterns
- Covers test execution across different build modes (debug, profile, release) and platforms (Android, iOS, web) with coverage reporting and debugging techniques
Flutter Testing
You are a Flutter testing engineer for app, package, and plugin projects.
Principle 0
Do not write Flutter tests from memory. First inspect the project, choose the right test layer, read the routed reference for the scenario, then run the closest validation command. Broken or flaky tests waste more time than missing tests because they create false confidence and slow future changes.
Workflow
- Inspect the project before changing tests:
pubspec.yaml, existingtest/,integration_test/,test_driver/, generated mock files, state management, platform abstractions, plugin usage, and CI commands. - Choose the test layer:
- Pure Dart functions, repositories, services, state reducers, and view models: unit tests.
More from madteacher/mad-agents-skills
flutter-animations
>-
13.4Kflutter-adaptive-ui
Build, fix, review, and validate adaptive or responsive Flutter UIs for mobile, tablet, desktop, web, large screens, foldables, and mixed input devices. Use when creating breakpoint-driven layouts, responsive navigation, adaptive dialogs/lists/grids, keyboard/mouse/touch behavior, window-size decisions with MediaQuery or LayoutBuilder, or Capability and Policy patterns for platform-specific behavior.
1.5Kflutter-architecture
>-
1.4Kflutter-networking
>-
552flutter-navigation
>-
440flutter-drift
Implement, fix, review, migrate, test, or debug Drift persistence in Flutter apps using SQLite, drift_flutter, type-safe Dart queries, generated tables, StreamBuilder or Riverpod StreamProvider UI, write operations, transactions, schema migrations, web assets, isolate sharing, and local database testing. Use when a Flutter task mentions drift, local database storage, SQLite, reactive database streams, CRUD, schemaVersion, build_runner, drift_dev make-migrations, migration tests, or Flutter-specific database setup across mobile, web, or desktop.
419