Installation
Install the extension
Install the extension from VS Code Marketplace or Open VSX Registry for other VS Code-based editors like Cursor.
The Patrol extension requires the Dart extension. If you don’t have it installed, you’ll be prompted to install it.
Configure test directory (optional)
If your tests are not in the default
patrol_test directory, add this to your pubspec.yaml:pubspec.yaml
patrolTest invocations in your code.
Features
Test Explorer Integration
The extension adds a dedicated Patrol section to VS Code’s Test Explorer:View all Patrol tests
View all Patrol tests
All Patrol tests in your project are automatically discovered and displayed in a hierarchical tree view in the Test Explorer sidebar.
Run individual tests
Run individual tests
Click the play button next to any test file to run it on the currently selected device.
Run all tests
Run all tests
Use the play button at the top of Test Explorer to run all Patrol tests in your project.
Debug tests
Debug tests
Click the debug icon next to a test file to start a debugging session with breakpoint support.
In-Editor Test Controls
Run tests directly from your code editor:- Green play button: Appears next to
patrolTest()invocations - Quick execution: Click to instantly run the test on your selected device
- Multiple tests: Running a test file with multiple tests executes all of them
Live Test Results
Monitor test execution in real-time:- Test Results tab: View logs and results from the latest test run
- Live logs: See test output as it happens during execution
- Execution status: Visual indicators show which tests are running, passed, or failed
- Stop button: Halt test execution at any time using the stop button in the toolbar
Debugging with Hot Restart
The extension integrates Patrol’sdevelop command with VS Code’s debugging capabilities:
Wait for debugger to attach
The test will build and start executing. After a moment, the VS Code debugger will attach, and you’ll see the debugging toolbar.
Use debugging features
- Set breakpoints in your test code
- Step through code execution
- Inspect variables and call stacks
- Use the debug console
Debugging uses Patrol’s
develop mode, which keeps the test running after completion. This allows you to hot restart and iterate quickly.Debugging Toolbar
The debugging toolbar provides several controls:- Pause/Continue: Pause execution or continue to the next breakpoint
- Step Over: Execute the current line and move to the next
- Step Into: Step into function calls
- Step Out: Step out of the current function
- Disconnect: Disconnect the debugger but leave the test running
- Hot Restart: Restart the test without rebuilding
- Stop: Stop the test and close the app
- Widget Inspector: Open the Flutter Widget Inspector
DevTools Integration
Access Flutter DevTools during debugging sessions:From popup notification
From popup notification
When debugging starts, a popup appears with an option to open DevTools.
From command palette
From command palette
- Open the Command Palette (
Cmd+Shift+PorCtrl+Shift+P) - Search for “DevTools”
- Select which DevTools panel to open
Patrol’s DevTools extension for inspecting native UI elements is only available in the web browser version of DevTools.
Custom Command Arguments
Configure additional arguments for Patrol CLI commands:- Open VS Code Settings (
Cmd+,orCtrl+,) - Search for “Patrol”
- Add custom arguments for
patrol testandpatrol developcommands
Device Selection
The extension uses the device currently selected in VS Code:- Open the Command Palette
- Search for “Flutter: Select Device”
- Choose your target device or emulator
Requirements
Patrol CLI
The extension requires
patrol_cli to be installed and available in your PATH. Install it globally:Dart Extension
The official Dart extension must be installed for the Patrol extension to function.
Troubleshooting
Tests don't appear in Test Explorer
Tests don't appear in Test Explorer
- Verify your test directory configuration in
pubspec.yaml - Check that test files use
patrolTest()or your annotated wrapper - Reload the window: Command Palette > Developer: Reload Window
Can't run tests from Test Explorer
Can't run tests from Test Explorer
This is a known bug in some VS Code versions where the PATH environment variable isn’t properly imported. Update VS Code to the latest version.
Widget Inspector shows no widgets
Widget Inspector shows no widgets
Enable the “Show implementation widgets” toggle in the Widget Inspector toolbar.
New tests not appearing
New tests not appearing
After creating new test files, reload the window:Command Palette > Developer: Reload Window
Debugging doesn't start
Debugging doesn't start
Ensure:
patrol_cliis installed and in your PATH- A device is selected in VS Code
- Your test file has no syntax errors
Best Practices
Use Test Explorer for test organization
Keep Test Explorer open to easily navigate and run your test suite.
Leverage hot restart during debugging
Instead of stopping and restarting, use hot restart to iterate quickly on test changes.
Configure custom arguments
Set up project-specific Patrol CLI arguments in VS Code settings to avoid typing them repeatedly.
Next Steps
DevTools Extension
Learn about Patrol’s DevTools extension for native UI inspection.
Writing Tests
Start writing Patrol tests with custom finders.
Native Automation
Add native automation to your tests.
Logging
Configure logging for better test debugging.