question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Evaluate code in Debug Console during integration tests

See original GitHub issue

Describe the bug

TL;DR I can’t evaluate code in Debug Console when running integration tests. I don’t know if I’m doing something wrong or if this is just not possible.

Also, I can’t find a way to run (using VS Code’s launch.json) normal widget tests with flutter run test/widget_test.dart (=running on device) instead of flutter test test/widget_test.dart (running in isolation). This might be another issue, though.

To Reproduce

TL;DR Run any Flutter integration test with VS Code and try to evaluate Dart code in the Debug Console.

Create .vscode/launch.json in the root of a Flutter project with the following contents:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "flutter run app",
      "request": "launch",
      "type": "dart",
      "program": "lib/main.dart"
    },
    {
      "name": "flutter run integration tests",
      "request": "launch",
      "type": "dart",
      "program": "integration_test/example_test.dart"
    },
  ]
}
  1. Clone the repository of the Patrol framework
  2. Open the example app directory with VS Code ($ code .). It’s located in packages/patrol/example
  3. Now that you’re in the example app’s dir, put a breakpoint somewhere in the integration_test/example_test.dart file, for example on line 16:
    await $(FloatingActionButton).tap();
    
  4. Run the flutter run integration tests configuration from launch.json
  5. Try to evaluate some code in the Debug Console.
  6. See _compileExpression: No compilation service available; cannot evaluate from source..

Screenshot 2022-10-07 at 12 55 27 AM

Expected behavior

Being able to evaluate Dart code in Debug Console when the test is stopped on a breakpoint.

This is how it works with widget tests running in isolation:

https://user-images.githubusercontent.com/40357511/194433392-ee580ce9-764f-4cc0-8e73-c12c282c70c6.mov

System info

  • Operating System and version: macOS 12.6 on MacBook Air M1
  • VS Code version: 1.72.0
  • Dart extension version: v3.50.0
  • Dart/Flutter SDK version: Dart 2.18.2, Flutter 3.3.3
  • Target device: Android emulator (Pixel 5 API 33)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
DanTupcommented, Oct 15, 2022

Re-opening this as a reminder because I think I have this working but need to come back to it.

1reaction
DanTupcommented, Oct 25, 2022

I landed a fix for this in Flutter. It should be available on master now, and in some future stable Flutter SDK release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging in Visual Studio Code
Expressions are evaluated after you press Enter and the Debug Console REPL shows suggestions as you type. If you need to enter multiple...
Read more >
Support expresssion evaluation when debugging Integration ...
Users today with flutter test are able to evaluate arbitrary expressions with an IDE while ... Evaluate code in Debug Console during integration...
Read more >
Debug unit tests with Test Explorer - Visual Studio (Windows)
In Test Explorer, select the test method(s) and then choose Debug on the right-click menu. Test execution details. For more information, about ...
Read more >
Running integration tests against the server in the same solution
The tests need to talk to a TCP server in the same solution and it'd like to debug both the test and the...
Read more >
Evaluate expressions in runtime using Console
Define, declare, and verify new variables and functions while you debug a script in runtime using Console. The script execution must be paused ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found