Quick reference guide for testing in the Flutter Starter project.
Run the same gates CI uses for Dart code (no Android/iOS/Web builds):
./scripts/dev/audit_template.shOr step by step:
./scripts/dev/format_dart.sh --check # or: dart format --set-exit-if-changed lib test integration_test tool bricks
flutter analyze
flutter testOptional (slower, matches coverage job): flutter test --coverage --timeout=5m. See CONTRIBUTING.md for full contribution flow.
flutter test./scripts/test/test_coverage.sh --htmlEnsure you have patrol_cli installed:
dart pub global activate patrol_cli
./scripts/test/run_e2e_tests.sh./scripts/test/calculate_layer_coverage.sh| Layer | Target |
|---|---|
| Domain | 100% |
| Data | 90%+ |
| Core | 80%+ |
| Presentation | 80%+ |
| Overall | 80%+ |
test/
├── helpers/ # Test utilities
├── core/ # Core layer tests
├── features/ # Feature layer tests
├── shared/ # Shared components
├── integration/ # Standard integration tests
└── integration_test/# E2E Patrol tests (e.g. auth_flow_test.dart)
- Test Helpers:
test/helpers/test_helpers.dart - Test Fixtures:
test/helpers/test_fixtures.dart - Coverage Script:
scripts/test/test_coverage.sh - Analysis Script:
scripts/test/calculate_layer_coverage.sh
- ✅ Quality gate on every push/PR to
main(.github/workflows/ci.yml): format → analyze → unit tests on one runner (keeps GitHub Actions minutes low; branch protection can require Quality gate). - ✅ Coverage thresholds (overall ≥80%, domain 100%, data ≥90%, presentation/core ≥80%) run in
.github/workflows/coverage.yml(manual Run workflow and weekly schedule), not on every PR. - ✅ Codecov upload and optional PR comments live in that coverage workflow when you enable triggers that include pull requests.
Patrol E2E does not block PRs. To run on CI: open Actions → E2E Android (Patrol) → Run workflow. Requires a working backend if the login flow calls your API. Integration tests use stable ValueKeys from lib/core/constants/ui_keys.dart.
- 📖 Testing Guide - Comprehensive testing guide
- 📊 Coverage Guide - Coverage measurement and improvement
- 📝 Test README - Test directory documentation
- 📂 Repository layout (non-platform) - Where tests and tools live in the tree
# Format Dart (same scope as CI — avoids formatting `build/`)
./scripts/dev/format_dart.sh
# Run all tests
flutter test
# Run with coverage
flutter test --coverage
# Generate HTML report
./scripts/test/test_coverage.sh --html --open
# Analyze by layer
./scripts/test/calculate_layer_coverage.sh
# Run specific test
flutter test test/features/auth/domain/usecases/login_usecase_test.dart- ✅ Use AAA pattern (Arrange, Act, Assert)
- ✅ Mock all dependencies
- ✅ Test edge cases
- ✅ Keep tests fast (<100ms)
- ✅ Use descriptive test names
- ✅ Test error scenarios