This document explains how to run Patrol integration tests in the Grammafy app. Patrol provides advanced UI testing capabilities with native automation features.
dart pub global activate patrol_cli-
Option A: Android Studio Emulator
- Open Android Studio
- Start an Android emulator (API 28+ recommended)
-
Option B: Physical Device
- Connect Android device via USB
- Enable Developer Options and USB Debugging
- Run
flutter devicesto verify connection
# Check if patrol is available
patrol --version
# Check if device/emulator is detected
flutter devices# Run all integration tests with live app interaction
patrol test
# Run specific test file
patrol test integration_test/grammar_correction_flow_test.dart
# Run with development mode (hot restart support)
patrol develop# Standard Flutter integration test (no native automation)
flutter test integration_test/
# Specific test file
flutter test integration_test/grammar_correction_flow_test.dart# Run complete test suite (includes integration tests)
./test_runner.sh- The integration test launches the actual Grammafy app
- You'll see the app running on your emulator/device
- Tests interact with the real UI elements
- Tap tone selection chips (Formal, Neutral, Friendly)
- Enter text in the grammar input field
- Tap send/paste buttons
- Verify UI state changes
- Grammar Correction Workflow: Complete user journey
- Error Handling: Edge cases and error states
- Conversation History: Multiple message handling
- Performance Testing: Rapid interactions
- Native Automation: System-level interactions (when available)
🚀 Integration Test Execution:
├── App launches automatically
├── Tests execute UI interactions
├── Real user workflows are validated
├── Performance and stability verified
└── Results reported in terminal
integration_test/
└── grammar_correction_flow_test.dart # Main integration tests
├── Grammar correction complete workflow
├── Error handling workflow
├── Conversation history workflow
├── App bar interactions
├── Rapid user interactions stress test
├── Native automation features
└── UI responsiveness and performance
# Check connected devices
flutter devices
# For emulator issues
flutter emulators --launch <emulator_name># Reinstall Patrol CLI
dart pub global deactivate patrol_cli
dart pub global activate patrol_cli
# Verify PATH includes pub global packages
echo $PATH# Clean build cache
flutter clean
flutter pub get
# Rebuild and test
flutter build apk --debug# Check if emulator is responsive
adb devices
# Restart ADB if needed
adb kill-server
adb start-serverFor debugging integration tests:
# Run with verbose output
patrol test --verbose
# Run in development mode with hot restart
patrol develop
# Run specific test with Flutter debug
flutter test integration_test/grammar_correction_flow_test.dart --verboseThe integration tests include examples of Patrol's native automation:
// Network conditions
await $.native.enableCellular();
await $.native.disableWifi();
// System interactions
await $.native.enableDarkMode();
await $.native.pressHome();
// Permissions
await $.native.grantPermissionWhenInUse();
// Notifications
await $.native.openNotifications();
await $.native.tapOnNotificationByIndex(0);Tests include performance validation:
- Rapid UI interactions
- Memory usage monitoring
- Response time verification
- Stability under load
For automated testing in CI/CD pipelines:
# GitHub Actions example
- name: Run Patrol Integration Tests
run: |
patrol test --no-device-finder
env:
FLUTTER_TEST_ENVIRONMENT: ci- Keep tests independent - Each test should set up its own state
- Use realistic data - Test with real-world scenarios
- Handle timing - Use
await $.pumpAndSettle()appropriately - Test error cases - Include negative test scenarios
- Verify end states - Always check final UI state
- Test execution time: 30-60 seconds per test scenario
- App startup: 3-5 seconds on emulator
- UI interactions: Near real-time response
- Memory usage: Monitored and validated
This setup ensures comprehensive end-to-end testing of the Grammafy app's core functionality with real device interactions.