patrol develop command enables rapid test development by leveraging Flutter’s Hot Restart feature. Make changes to your tests and see results instantly without rebuilding.
Synopsis
Description
patrol develop builds your app once, then allows you to iterate quickly on test code using Hot Restart. After the initial build completes, press R to restart your tests with code changes applied instantly.
This dramatically speeds up the test development workflow:
- No rebuilds - Only the initial build is required
- Instant feedback - Press R to restart with changes
- Live development - Edit tests and see results immediately
Hot Restart only restarts the Flutter part of your app. Native code changes require a full rebuild.
Basic Usage
Start developing a test
Workflow
Wait for initial build
The first build takes the usual time. Once complete, the app launches and tests run.
Required Options
The test file to develop with Hot Restart. Only one target is allowed.
Device Selection
Specify which device to run on.
Build Configuration
Build Mode
Run in debug mode (default and only supported mode).
Flavors
Build a specific flavor of your app.
Build Versioning
Set custom build name (version).
Set custom build number (version code).
Dart Defines
Pass environment variables to your app.
Load environment variables from a file.
Test Execution Options
Uninstall the app before starting.
Hide individual test steps from output.
Clear test steps after each test run.
Display label overlay on the app.
Platform-Specific Options
Android
Override the Android package name.
iOS
Override the iOS bundle identifier.
Specify iOS version for simulators.
DevTools Integration
Automatically open Patrol extension in DevTools when ready.
Advanced Options
Port for the test instrumentation server.
Port for the app under test server.
Verify dependency compatibility.
Examples
Demo
Watch Hot Restart in action:Caveats and Limitations
patrol develop is powerful, but it has important limitations to understand.
Flutter vs Native Restart
Flutter apps consist of two parts: native and Flutter. Hot Restart only restarts the Flutter part. When you press R:- ✅ Flutter code restarts (your
main()runs again) - ❌ Native code does NOT restart
- ❌ App data is NOT cleared
- ❌ App is NOT uninstalled
Platform Support
Supported platforms:- ✅ Android emulators
- ✅ Android physical devices
- ✅ iOS simulators
- ❌ iOS physical devices (unreliable)
- ❌ macOS
- ❌ Web
State Persistence
Because Hot Restart doesn’t clear app state, you need to handle these scenarios:Permissions
Once granted, permissions cannot be revoked without killing the app. When the app dies, Hot Restart stops. Workaround: Handle both granted and not-granted states in your tests.File System
Files created in internal storage persist between Hot Restarts. Workaround: Clean up files at the start or end of your tests.Shared Preferences
Data saved to SharedPreferences persists between Hot Restarts. Workaround: Clear preferences in your test setup.Native State
Native code that runs only on app launch won’t re-execute on Hot Restart. Impact: If your app initializes native SDKs or services on startup, they won’t be re-initialized.Best Practices
Use simulators/emulators
Avoid physical iOS devices. Use iOS simulators or Android emulators for reliable Hot Restart.
Hot Restart vs Hot Reload
| Feature | Hot Restart | Hot Reload |
|---|---|---|
| Speed | Fast (~1s) | Very fast (<1s) |
| Preserves state | No | Yes |
| Runs main() | Yes | No |
| Supported by Patrol | Yes | No |
Troubleshooting
Hot Restart not activating
If Hot Restart doesn’t become available:- Wait a few seconds after the app starts
- Check terminal for error messages
- Ensure you’re using a supported platform (not physical iOS)
- Try restarting the develop command
Changes not applying
If pressing R doesn’t apply changes:- Verify your file is saved
- Check for compilation errors
- Ensure changes are in Flutter code, not native code
- Try a full rebuild with
patrol test
App crashes on restart
If the app crashes when pressing R:- Check for state-related issues (permissions, files, etc.)
- Review native code that may not handle restart well
- Add proper cleanup in test setup
- Check logs for error details
Related Commands
- patrol test - Run tests with full builds
- patrol build - Build test binaries
- patrol devices - List available devices