- Home
- Skills
- Madteacher
- Mad Agents Skills
- Flutter Testing
flutter-testing_skill
17
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill madteacher/mad-agents-skills --skill flutter-testing- SKILL.md11.9 KB
Overview
This skill provides practical, comprehensive guidance for testing Flutter apps across unit, widget, and integration tests. It explains when to use each test type, how to mock plugins and platform channels, and how to run and debug tests in different build modes. The content focuses on actionable patterns, common errors, and CI-friendly workflows.
How this skill works
The skill inspects common testing needs and recommends the appropriate test level: unit tests for isolated logic, widget tests for UI components and interactions, and integration tests for full end-to-end flows. It shows concrete examples for test structure, finding widgets, user interactions, mocking platform channels, and performance measurement. It also covers build modes (debug/profile/release), plugin testing, and running tests across platforms and CI.
When to use it
- Write unit tests for pure functions, business logic, and state management
- Use widget tests to verify rendering, interactions, and layout under different conditions
- Run integration tests for complete user flows and multi-screen navigation
- Mock platform channels when code depends on plugins or native APIs
- Profile performance in profile mode and validate release-mode behavior
Best practices
- Follow the test pyramid: many unit/widget tests, fewer integration tests
- Name tests descriptively and use Arrange-Act-Assert structure
- Keep tests independent; avoid shared state between tests
- Mock external services and platform channels to keep tests fast and reliable
- Run tests in CI and include coverage reporting
Example use cases
- Unit test a data transformer or validation function with Mockito for external calls
- Widget test a form: find fields, enter text, tap submit, assert validation messages
- Integration test login flow across screens on an emulator or device
- Mock a plugin method channel in widget tests to simulate native responses
- Measure scrolling performance with tester.trace and analyze timeline frames
FAQ
If you only need to verify a single component or interaction, use a widget test. If you need to validate navigation, multiple screens, or real device behavior, choose an integration test.
How do I test code that calls plugins?
Mock the plugin's MethodChannel in unit/widget tests using TestDefaultBinaryMessengerBinding and setMockMethodCallHandler. For full plugin testing, include native test code and follow plugin testing guides.