You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run test using code lens does not open Test Results view #4951
I'm guessing this is the correct repo as my issue in vscode repo was closed (microsoft/vscode#202895).
Describe the bug
A clear and concise description of what the bug is.
When using the "Run" code lens button, I'd like vscode to open the Test Results view. It sometimes opens the Debug Console and other times the only noticeable UI change is a badge number indicator showing on the Test Explorer icon. If I use the green button to the left in the "well" (I think that's what the area is called), then it does switch to the Test Results view.
If I change "testing.openTesting" to "openExplorerOnTestStart", then the code lens Run button only shows the badge indicator while the test is running (or maybe it sometimes will show Debug Console inconsistently as above, but I didn't see that). The green test button in the well does open the Text Explorer as configured.
To Reproduce
Steps to reproduce the behavior:
Go to a dart test
Click on the "Run" code lens button
Expected behavior
Open Test Results view
Screenshots
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.
Operating System and version: "Windows 10 Pro" 10.0 (Build 22631)
VS Code version: win 1.85.2
Dart extension version: 3.80.0
Dart/Flutter SDK version: 3.2.2/3.16.2
Target device (if the issue relates to Flutter debugging):
@connor4312 when you click the CodeLens links here, we call vscode.TestController.createTestRun() so I would have expected it to handle this.
I'm going to try to fix this up by reading the value of openExplorerOnTestStart, but this feels a bit hacky (because if that setting changes, I need to keep in-sync). It would be nice if this could be handled automatically.
@connor4312 actually, I'm a bit confused about this setting...
The issue above mentions OpenExplorerOnTestStart but that seems to be about opening the Test Explorer, but the bug here is with the Test Results. It seems there's also an option for openOnTestStart (the default), however it's not clear to me what openOnTestStart means for the explorer (or what OpenExplorerOnTestStart` means for the test results). Is it possible to expand the descriptions on these enum values?
@DanTup Looking back, I'm not sure why I mentioned openExplorerOnTestStart - I guess I was just showing the setting that controlled this and that the Run button didn't seem to respect the setting. Worse, I failed to mention that openOnTestStart was the setting I was actually interested in.
@connor4312 can provide a more authoritative answer, but the comments on the settings seem to state that openOnTestStart should open the Test Results view...
// Controls when the testing view should open.
// - neverOpen: Never automatically open the testing views
// - openOnTestStart: Open the test results view when tests start
// - openOnTestFailure: Open the test result view on any test failure
// - openExplorerOnTestStart: Open the test explorer when tests start
"testing.openTesting": "openOnTestStart",
--
Before I had mentioned that the Debug Console view sometimes shows inconsistently. To get the screenshot above, I used the green button in the well. It initially showed the Test Results view as configured, but then switched to the Debug Console. When I pressed it again, it switched to the Test Results view and stayed there.
I'm unclear as to why this behavior changes or even who's responsible for it, but it may simply be something that only happens on first run - I just thought I should mention it.
Before I had mentioned that the Debug Console view sometimes shows inconsistently. To get the screenshot above, I used the green button in the well. It initially showed the Test Results view as configured, but then switched to the Debug Console. When I pressed it again, it switched to the Test Results view and stayed there.
Yeah, I noticed when testing this that setting openOnTestStart will cause Test Results to be shown when the test run starts, but then Debug Console is shown automatically as a debug session starts afterwards. So unless you have them side-by-side, you'll probably always end up on the Debug Console. But if they are side-by-side, it still feels like openOnTestStart should apply to these programmatic invocations of tests and not require a language extension to re-implement whatever the logic is for that setting.
I'm hoping @connor4312 agrees and this could be fixed in VS Code, but if there's a reason that can't be done, we should handle it here so it at least appears consistent.
The reason the setting isn't used when started from the extension is that I don't want UI changes to be triggered by something the user didn't explicitly due. Before there was a proper "watch" mode (and even now that there is one) some extensions start test runs in the background / run tests continuously, and I don't want that leading to a bad experience for users.
Is the only point where this is needed by Dart for code lenses? I had an issue for that for a couple years but closed it since there wasn't much community interest in it, but we could revive it...
Before there was a proper "watch" mode (and even now that there is one) some extensions start test runs in the background / run tests continuously, and I don't want that leading to a bad experience for users.
Ah, that makes sense.
Is the only point where this is needed by Dart for code lenses?
There are some other places like the "Rerun Last Test Session" command (because the built-in command doesn't work for some cases - see discussion at microsoft/vscode#144169 (comment)), but I presume this also impacts pressing F5 to run the test file?
Maybe we could pass a bool when we start a test run to indicate it was/was-not user-initiated, which you could use a signal to show things like Test Explorer/Test Results based on user settings? I guess in some ways this is similar to the contexts we get for things like Code Actions/Format (to know if we're running on-save versus user-invoked).
I've committed a fix for this that will be included in the next Dart-Code release, but it also requires a VS Code update to apply (which usually ships a week or so into each month).
Activity
DanTup commentedon Jan 22, 2024
@connor4312 when you click the CodeLens links here, we call
vscode.TestController.createTestRun()so I would have expected it to handle this.I'm going to try to fix this up by reading the value of
openExplorerOnTestStart, but this feels a bit hacky (because if that setting changes, I need to keep in-sync). It would be nice if this could be handled automatically.I found the code that handles this at https://github.com/microsoft/vscode/blob/236d5dc072622d511e2f8f6ddd83fd24a7165467/src/vs/workbench/contrib/testing/browser/testingProgressUiService.ts#L43 but I don't know why
createTestRunwouldn't trigger this code (I'm not familiar with this code).DanTup commentedon Jan 22, 2024
@connor4312 actually, I'm a bit confused about this setting...
The issue above mentions
OpenExplorerOnTestStartbut that seems to be about opening the Test Explorer, but the bug here is with the Test Results. It seems there's also an option foropenOnTestStart(the default), however it's not clear to me whatopenOnTestStart means for the explorer (or whatOpenExplorerOnTestStart` means for the test results). Is it possible to expand the descriptions on these enum values?Move ability to get resolved config to config class
jibbers42 commentedon Jan 22, 2024
@DanTup Looking back, I'm not sure why I mentioned
openExplorerOnTestStart- I guess I was just showing the setting that controlled this and that the Run button didn't seem to respect the setting. Worse, I failed to mention thatopenOnTestStartwas the setting I was actually interested in.@connor4312 can provide a more authoritative answer, but the comments on the settings seem to state that
openOnTestStartshould open the Test Results view...--
Before I had mentioned that the Debug Console view sometimes shows inconsistently. To get the screenshot above, I used the green button in the well. It initially showed the Test Results view as configured, but then switched to the Debug Console. When I pressed it again, it switched to the Test Results view and stayed there.
I'm unclear as to why this behavior changes or even who's responsible for it, but it may simply be something that only happens on first run - I just thought I should mention it.
DanTup commentedon Jan 24, 2024
Yeah, I noticed when testing this that setting
openOnTestStartwill cause Test Results to be shown when the test run starts, but then Debug Console is shown automatically as a debug session starts afterwards. So unless you have them side-by-side, you'll probably always end up on the Debug Console. But if they are side-by-side, it still feels likeopenOnTestStartshould apply to these programmatic invocations of tests and not require a language extension to re-implement whatever the logic is for that setting.I'm hoping @connor4312 agrees and this could be fixed in VS Code, but if there's a reason that can't be done, we should handle it here so it at least appears consistent.
connor4312 commentedon Jan 30, 2024
The reason the setting isn't used when started from the extension is that I don't want UI changes to be triggered by something the user didn't explicitly due. Before there was a proper "watch" mode (and even now that there is one) some extensions start test runs in the background / run tests continuously, and I don't want that leading to a bad experience for users.
Is the only point where this is needed by Dart for code lenses? I had an issue for that for a couple years but closed it since there wasn't much community interest in it, but we could revive it...
DanTup commentedon Jan 30, 2024
Ah, that makes sense.
There are some other places like the "Rerun Last Test Session" command (because the built-in command doesn't work for some cases - see discussion at microsoft/vscode#144169 (comment)), but I presume this also impacts pressing
F5to run the test file?Maybe we could pass a bool when we start a test run to indicate it was/was-not user-initiated, which you could use a signal to show things like Test Explorer/Test Results based on user settings? I guess in some ways this is similar to the contexts we get for things like Code Actions/Format (to know if we're running on-save versus user-invoked).
DanTup commentedon Mar 26, 2024
@connor4312 any thoughts on the above?
connor4312 commentedon Apr 3, 2024
I've made an API proposal here: microsoft/vscode#209491
DanTup commentedon Apr 4, 2024
Thanks! :)
DanTup commentedon Apr 23, 2024
I've committed a fix for this that will be included in the next Dart-Code release, but it also requires a VS Code update to apply (which usually ships a week or so into each month).