- Home
- Skills
- Kaakati
- Rails Enterprise Dev
- Testing Patterns
testing-patterns_skill
- Shell
6
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 kaakati/rails-enterprise-dev --skill testing-patterns- SKILL.md8.1 KB
Overview
This skill documents pragmatic testing patterns for Flutter/Dart projects: unit, repository, controller, widget, integration, and golden tests with clear mocking strategies. It presents repeatable examples that fit enterprise Rails-aligned workflows but remain portable across any codebase. The focus is on reliable, maintainable tests that support CI quality gates and multi-agent orchestration.
How this skill works
The skill outlines what to inspect and how to mock at each layer: use-case and controller units with mock use cases/repositories, repository tests that toggle network/local paths, widget tests that inject mocked controllers, integration tests driving full flows, and golden tests validating visual output. Each pattern shows arrange-act-assert structure, verification of interactions, and cleanup steps to avoid test pollution.
When to use it
- Unit tests for domain logic and small data transformations
- Repository tests when behavior depends on network/local sources and caching
- Controller tests to validate state management and error handling
- Widget tests for UI logic with injected mock controllers
- Integration tests for critical user flows across screens and services
- Golden tests to lock visual regressions for key components
Best practices
- Keep unit tests focused: one behavior per test and explicit arrange-act-assert
- Prefer mocks for external dependencies and verify interactions to catch regressions
- Test both online and offline repository branches and cache behavior
- Use dependency injection (or service locators) to inject mocks in widget tests and clean up after each test
- Limit golden tests to stable components and run them in consistent environments
- Run integration tests selectively in CI and keep them deterministic by avoiding flaky waits
Example use cases
- Validate a GetUser use-case returns domain entities and handles failures
- Ensure repository fetches remote data when online and returns cached data when offline
- Confirm controller toggles loading and error states correctly for UI consumers
- Assert UserPage shows loader, data, or error by injecting a mocked controller
- Run a full login flow in an integration test to verify end-to-end navigation
- Capture a UserCard golden to prevent visual regressions in the app shell
FAQ
Use widget tests for isolated UI behavior with mocked dependencies; use integration tests for end-to-end flows involving navigation, platform plugins, or real data paths.
When should I use golden tests?
Use golden tests for stable, visually critical components where pixel-perfect output matters, and run them in a consistent environment to avoid false positives.
How to avoid flaky integration tests?
Make tests deterministic: prefer pumpAndSettle over arbitrary delays, stub network calls where feasible, and keep environment setup consistent in CI.