develop command brings Flutter’s Hot Restart capability to integration tests, dramatically speeding up the test development cycle. Instead of rebuilding and reinstalling your app for every test change, you can restart just the Flutter portion of your app in seconds.
The patrol develop Command
Thedevelop command is one of Patrol CLI’s most powerful features for productivity:
Basic Usage
- Builds your app and test instrumentation (initial build is slow)
- Installs and launches the app on your device
- Activates Hot Restart after a short initialization
- Lets you press R to restart the test instantly
The first run involves a full build and is slow. Subsequent restarts (by pressing R) take only seconds!
How Hot Restart Works
Understanding Hot Restart’s mechanics is crucial for writing reliable tests:What Gets Restarted
When you press R, Flutter’s Dart VM restarts:
- Your
main()function runs again - All Dart code is reloaded with your changes
- Widget tree is rebuilt from scratch
- Test code executes from the beginning
Basic Usage
Start develop session
Press R to restart
In the terminal where
patrol develop is running, press R. Your changes take effect immediately!Advanced Options
Customize the develop command with additional flags:Writing Hot Restart-Friendly Tests
Since state persists across restarts, you need to design tests accordingly:Handle Persistent State
Clean Up Between Restarts
Create helper functions to reset state:Helper Functions
Handling Permissions
Permissions are the most common Hot Restart challenge:Strategy: Handle Both Permission States
Permission-Aware Test
File System Persistence
Files created during tests remain across restarts:File Cleanup Example
Native State Considerations
Native code that runs only once (on app launch) won’t re-execute:Platform Limitations
Real-World Workflow
Here’s a typical development session:Troubleshooting
Hot Restart Not Available
Hot Restart doesn't activate
Hot Restart doesn't activate
Possible causes:
- App hasn’t finished launching - Wait 10-15 seconds after launch
- Compilation errors - Check terminal for Dart errors
- Platform not supported - Verify you’re not on physical iOS or web
Test Fails on Restart
Test passes first time but fails on restart
Test passes first time but fails on restart
Cause: State persisting from previous runSolutions:
-
Add cleanup at test start:
-
Handle both states:
- Make operations idempotent
App Crashes on Restart
App crashes when pressing R
App crashes when pressing R
Possible causes:
- State inconsistency - Native and Dart state out of sync
- Memory leak - Resources not cleaned up properly
- Hot restart bug - Edge case in Flutter
- Restart the entire develop session
- Add more cleanup code
- Check for memory leaks in your app
Demo Video
Watch Hot Restart in action:Comparing Hot Restart to Hot Reload
It’s important to understand the difference:| Feature | Hot Reload | Hot Restart |
|---|---|---|
| Speed | ~1 second | ~3-5 seconds |
| State | Preserved | Lost |
| Use case | UI tweaks | Logic changes |
main() | Not called | Called again |
| Availability | Development only | Development + tests |
Best Practices
Next Steps
Test Isolation
Learn how Patrol ensures clean test execution
CLI Reference
Full documentation for the develop command