Debugging Patrol tests
If you want to debug your application during patrol tests, you can do in Visual Studio Code by attaching a debugger to the running process. Here is how you can do it:
- In your
launch.json
file, add a new configuration for attaching debugger to a process:
{
"name": "attach debugger",
"request": "attach",
"type": "dart",
"cwd": "integration_test",
"vmServiceUri": "${command:dart.promptForVmService}"
}
-
Run your patrol tests using
develop
command with the same arguments as you would normally do. -
When the tests will start running, at some point you will see a message with a link to Patrol devtools extension. Copy the last part of the URI from the message. Eg. for this link:
Patrol DevTools extension is available at http://127.0.0.1:9104/patrol_ext?uri=http://127.0.0.1:52263/F2-CH29gR1k=/
copy
http://127.0.0.1:52263/F2-CH29gR1k=/
.You'll see 2 similar logs. First one looks like this:
The Dart VM service is listening on http://127.0.0.1:63725/57XmBI_pwSA=/
Ignore it - this link is incorrect, wait for the one that says about devtools extension.
-
From "Run and Debug" tab in Visual Studio Code, select the configuration you have created in step 1. You will be prompted to enter the VM service URI. Paste the URI you copied in step 3.
-
Once the debugger is attached, you can set breakpoints and debug your application as you would normally do.
Intellij/Android Studio does not support attaching a debugger to a running process via Observatory Uri. Therefore you cannot achieve the same behavior in those IDEs (See this issue).