Testing Guide
Overview
Comprehensive testing strategy for the AI-Powered Photo Journaling Flutter app covering unit tests, widget tests, integration tests, and manual testing procedures.Testing Philosophy
- Test early, test often: Write tests alongside features
- Pyramid approach: More unit tests, fewer integration tests
- Test behavior, not implementation: Focus on what, not how
- Maintainable tests: Keep tests simple and clear
Test Coverage Goals
- Unit Tests: 80%+ coverage for business logic
- Widget Tests: 70%+ coverage for UI components
- Integration Tests: Critical user flows covered
- Manual Tests: All features tested on real devices
Running Tests
All Tests
Specific Tests
Device Testing
Unit Testing
Testing Business Logic
File:test/features/entry/entry_service_test.dart
Testing Utilities
File:test/core/utils/date_utils_test.dart
Widget Testing
Testing UI Components
File:test/shared/widgets/buttons/primary_button_test.dart
Testing Screens
File:test/features/timeline/presentation/screens/timeline_screen_test.dart
BLoC Testing
File:test/features/entry/presentation/bloc/entry_bloc_test.dart
Integration Testing
Setup
Createintegration_test/app_test.dart:
Running Integration Tests
Manual Testing Checklist
Pre-Release Testing
Functional Testing
-
Entry Creation
- Capture photo from camera
- Select photo from library
- AI prompt generation works
- Can select and edit prompt
- Can add custom emotions
- Entry saves successfully
-
Timeline
- Entries display correctly
- Infinite scroll works
- Pull-to-refresh works
- Tap to view detail works
- Photos load correctly
-
Search
- Text search works
- Emotion filter works
- Date range filter works
- Results display correctly
-
Calendar
- Calendar displays correctly
- Can navigate months
- Entry indicators show
- Tap date to filter works
-
Settings
- Profile updates save
- Notification settings work
- Privacy settings work
- Data export works
Accessibility Testing
-
VoiceOver
- All buttons have labels
- Images have alt text
- Navigation works with VoiceOver
- Forms are accessible
-
Dynamic Type
- Text scales correctly
- Layouts don’t break with large text
- All text is readable
-
Color Contrast
- Meets WCAG AA standards
- Works in dark mode
- No color-only indicators
Performance Testing
-
App Launch
- Launches in < 2 seconds
- No visible lag
-
Scrolling
- Timeline scrolls at 60 FPS
- No dropped frames
- Smooth animations
-
Memory
- No memory leaks
- Memory usage stable
- No crashes after extended use
-
Network
- Works on WiFi
- Works on cellular
- Handles offline gracefully
Device Testing
Test on multiple devices:- iPhone 12 (iOS 15)
- iPhone 14 Pro (iOS 16)
- iPhone 15 Pro Max (iOS 17)
- iPad (latest iOS)
Edge Cases
-
Empty States
- No entries yet
- No search results
- No notifications
-
Error States
- Network error
- API error
- Invalid input
- Permission denied
-
Boundary Conditions
- Very long journal entry (10,000 characters)
- Many entries (1,000+)
- Large photo (25MB)
- Very old date
- Future date
Mocking
Mock Services
Create mocks for external dependencies:Golden Tests
Test visual appearance:CI/CD Integration
GitHub Actions (.github/workflows/test.yml):
Best Practices
-
Test Naming: Use descriptive names
- ✅
should create entry with valid data - ❌
test1
- ✅
-
Arrange-Act-Assert: Structure tests clearly
-
One Assertion Per Test: Keep tests focused
- Each test should verify one behavior
- Use multiple tests for multiple behaviors
-
Independent Tests: Tests should not depend on each other
- Each test should setup its own state
- Use
setUp()andtearDown()
-
Readable Tests: Write tests that document behavior
- Test names explain what is being tested
- Code is clean and easy to understand
Troubleshooting
Common Issues
Issue: Tests fail on CI but pass locally- Solution: Ensure consistent Flutter version, check timezone dependencies
- Solution: Wrap widget in
CupertinoApporMaterialApp
- Solution: Increase timeout, check for infinite loops
- Solution: Add proper waits with
pumpAndSettle(), check for race conditions
Last Updated: 2025-11-15 Maintained By: QA Engineer / Frontend Developer