Repository navigation
VS Code's new "Run Tests" / "Debug Tests" entries in the explorer context menu do not work for Dart/Flutter #5094
Description
Describe the bug
Dart code unable to find the tests for a newly generated Flutter project
To Reproduce
Steps to reproduce the behavior:
Create a new Flutter project via flutter create your_example.
Open the folder via code
Select the generated test and right-mouse click on widget_test.dart and select Run Tests.
-> Message that no tests is found (see below for screenshot).
Expected behavior
Test found and run.
That is was what happened in the past, AFAICS this "test not found" is something new.
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (F1) to easily capture this information or provide it manually.
!!
Workspace Environment
Dart Code extension: 3.88.0
Flutter extension: 3.88.0 (activated)
App: Visual Studio Code
App Host: desktop
Version: linux 1.88.1
Workspace type: Flutter (LSP)
Dart (3.5.0-131.0.dev): /home/vogella/git/flutter/bin/cache/dart-sdk
Flutter (3.22.0-23.0.pre.44): /home/vogella/git/flutter (sdk gphone64 x86 64 (android-x64/android))
Output from 'dart info'
/home/vogella/git/flutter/bin/cache/dart-sdk/bin/dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
General info
- Dart 3.5.0-131.0.dev (dev) (Fri May 3 09:02:58 2024 -0700) on "linux_x64"
- on linux / Linux 6.5.0-28-generic Set "priority files" in the analyser to the currently open files #29-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 28 23:46:48 UTC 2024
- locale is en_US.UTF-8
Project info
- sdk constraint: '>=3.2.5 <4.0.0'
- dependencies: flutter
- dev_dependencies: flutter_lints, flutter_test
Process info
| Memory | CPU | Elapsed time | Command line |
|---|---|---|---|
| 63 MB | 0.1% | 05:22 | dart devtools --machine --allow-embedding --dtd-uri ws:/9lPEeUHk02wCBm2A |
| 61 MB | 0.0% | 03:54:10 | dart devtools --machine --allow-embedding --dtd-uri ws:/FvQN6v2dGjZpb3zV |
| 64 MB | 0.0% | 02:02:57 | dart devtools --machine --allow-embedding --dtd-uri ws:/gPIcB0WEURHSoLxl |
| 1251 MB | 1.0% | 02:02:57 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.88.0 |
| 487 MB | 3.2% | 05:23 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.88.0 |
| 76 MB | 0.0% | 03:54:11 | dart tooling-daemon --machine |
| 76 MB | 0.0% | 02:02:57 | dart tooling-daemon --machine |
| 76 MB | 0.1% | 05:23 | dart tooling-daemon --machine |
| 86 MB | 0.1% | 02:02:57 | flutter_tools.snapshot daemon |
| 80 MB | 0.4% | 05:23 | flutter_tools.snapshot daemon |
| 77 MB | 0.0% | 02:01:01 | flutter_tools.snapshot debug_adapter |
| 159 MB | 0.2% | 02:01:00 | flutter_tools.snapshot run --machine --start-paused -d emulator-5554 --devtools-server-address http:/ --target /main.dart |
Output from 'flutter doctor'
/home/vogella/git/flutter/bin/flutter doctor -v
[✓] Flutter (Channel master, 3.22.0-23.0.pre, on Ubuntu 23.10 6.5.0-28-generic, locale en_US.UTF-8)
• Flutter version 3.22.0-23.0.pre on channel master at /home/vogella/git/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f6c8cc3fa0 (33 hours ago), 2024-05-06 01:57:33 -0400
• Engine revision c73fd390d1
• Dart version 3.5.0 (build 3.5.0-131.0.dev)
• DevTools version 2.35.0
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /home/vogella/Android/Sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /home/vogella/dev/android-studio/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 16.0.6 (15)
• cmake version 3.27.4
• ninja version 1.11.1
• pkg-config version 1.8.1
[✓] Android Studio (version 2022.3)
• Android Studio at /home/vogella/dev/android-studio/android-studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.88.1)
• VS Code at /snap/code/current/usr/share/code
• Flutter extension version 3.88.0
[✓] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• Linux (desktop) • linux • linux-x64 • Ubuntu 23.10 6.5.0-28-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.60
[✓] Network resources
• All expected network resources are available.
• No issues found!


Activity
DanTup commentedon May 7, 2024
This menu entry is new from VS Code (apparently I requested it 😄 microsoft/vscode#162728), but I guess we're not handling the kind of request it gives properly.
Our menu entries are these ones:
Those still seem to work in my testing. I'll investigate why the new VS Code one does not.
[-]No tests found in the selected file or folder[/-][+]VS Code's new "Run Tests" / "Debug Tests" entries in the explorer context menu do not work for Dart/Flutter[/+]vogella commentedon May 7, 2024
Thanks @DanTup
DanTup commentedon May 9, 2024
Seems like there may be multiple issues here. The first is that VS Code doesn't trigger test discovery when opening this (I've opened microsoft/vscode#212342), but even with that, it seems to only work on the folder and not the file in my testing - there's probably Dart-Code bugs here too.
DanTup commentedon May 9, 2024
The second issue above was also a VS Code issue - that's been fixed in latest code (verified in Insiders) via microsoft/vscode#211338.
DanTup commentedon Jun 10, 2024
The first issue has now also been fixed in VS Code (currently in insiders, will presumably ship in a stable at the start of next month).
mattbodley commentedon Oct 2, 2024
We are also finding this issue too in the latest version of vscode
DanTup commentedon Oct 3, 2024
@mattbodley please open a new issue with details of exactly what you're seeing and how to reproduce. I just had a quick test and things seem to be working for me, so there might be something else up here. Thanks!