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
When using variant parameter of testWidgets: No tests match regular expression.... when running individual tests #86659
Add the following parameter to existing testWidgets('Counter increment smoke test'..., variant: TargetPlatformVariant.desktop());
Attempt to run individual test and you'll get the error: No tests match regular expression...
There are NO other changes to the default code generated by flutter create, and only that one parameter to testWidgets causes the issue. Tests run if run from main, but not individual tests.
This happens because in VS Code when we run a single test, we put its name in the command line like this:
flutter test --machine --name "^Counter increments smoke test$" test/widget_test.dart
The --name argument is an exact match for the name of the test so that it doesn't match extra tests, for example if you had:
test('Counter increments', () {});
test('Counter increments when foo', () {});
Without the $ on the end of the name, trying to run the first test would actually run both.
When using variant, the name of the test is suffixed (in this case "Counter increments smoke test (TargetPlatform.windows)") and therefore no longer matches the pattern. The VS Code extension doesn't have enough information in the Outline data to know the variant exists, so it's hard to amend the expression.
@jonahwilliams any thoughts on this? Is there a way that --name could take variation into account? Or could we perhaps make the name slightly more specific so my regex could account for it without being too greedy (for example "Counter increments smoke test (variant: TargetPlatform.windows)")?
We could make the output include "variant:", sure.
I would point out that the IntelliJ plugin just executes all tests that contain the given test name, so there is a difference in functionality between the two plugins. I'm not commenting on which way is better, just that there's a difference (they both seem to have their merits to me).
It is sometimes useful to run only a particular variant, so you wouldn't want to make the regex too restrictive: I should be able to enter 'Counter increments (variant: TargetPlatform.windows)' and run just the Windows variant of the test.
I would point out that the IntelliJ plugin just executes all tests that contain the given test name, so there is a difference in functionality between the two plugins. I'm not commenting on which way is better, just that there's a difference (they both seem to have their merits to me).
It might make sense to align them. That's what VS Code used to do, but it felt like a bug that if the user clicked "Run" next to one, we might run other tests too. @stevemessick do you think it makes sense to update IntelliJ? I'm not familiar with the UI for IntelliJ so I don't know if it makes more sense there than in VS Code. In VS Code we're invoking i from these Run/Debug links above the testWidgets call:
That we're using the name of the test behind the scenes seems like a detail the user is hidden from, so running multiple looks strange.
I should be able to enter 'Counter increments (variant: TargetPlatform.windows)' and run just the Windows variant of the test
If we added a variant: prefix that would all still work in the cli. For VS Code there isn't anywhere you could choose to run one specific variant though, so clicking the Run/Debug links shown above would have to run all variants (described by the variant` argument).
So if we can add a variant: prefix in the test name, my plan would be to add ( \(variant: .*\))? to the end of the regex to match tests with exactly this name, but optionally with that variant suffix:
flutter test --name "^Counter increments smoke test( \(variant: .*\))?$" test/widget_test.dart
Does this sound reasonable? I can file a PR to add the text and ensure it doesn't break anything.
#86701 has landed in Flutter and Dart-Code/Dart-Code#3482 in the VS Code extension. The combination of these resolves this issue for VS Code (you'll need releases of both for this to start working). IntelliJ doesn't have this issue since its regex is less strict (though flutter/flutter-intellij#5650 will make this more aligned with VS Code's behaviour).
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
DanTup commentedon Jul 19, 2021
This happens because in VS Code when we run a single test, we put its name in the command line like this:
The
--nameargument is an exact match for the name of the test so that it doesn't match extra tests, for example if you had:Without the
$on the end of the name, trying to run the first test would actually run both.When using
variant, the name of the test is suffixed (in this case "Counter increments smoke test (TargetPlatform.windows)") and therefore no longer matches the pattern. The VS Code extension doesn't have enough information in the Outline data to know the variant exists, so it's hard to amend the expression.@jonahwilliams any thoughts on this? Is there a way that
--namecould takevariationinto account? Or could we perhaps make the name slightly more specific so my regex could account for it without being too greedy (for example "Counter increments smoke test (variant: TargetPlatform.windows)")?jonahwilliams commentedon Jul 19, 2021
I believe @gspencergoog added the variant feature, I would follow up with him
gspencergoog commentedon Jul 19, 2021
We could make the output include "variant:", sure.
I would point out that the IntelliJ plugin just executes all tests that contain the given test name, so there is a difference in functionality between the two plugins. I'm not commenting on which way is better, just that there's a difference (they both seem to have their merits to me).
It is sometimes useful to run only a particular variant, so you wouldn't want to make the regex too restrictive: I should be able to enter 'Counter increments (variant: TargetPlatform.windows)' and run just the Windows variant of the test.
DanTup commentedon Jul 19, 2021
It might make sense to align them. That's what VS Code used to do, but it felt like a bug that if the user clicked "Run" next to one, we might run other tests too. @stevemessick do you think it makes sense to update IntelliJ? I'm not familiar with the UI for IntelliJ so I don't know if it makes more sense there than in VS Code. In VS Code we're invoking i from these Run/Debug links above the
testWidgetscall:That we're using the name of the test behind the scenes seems like a detail the user is hidden from, so running multiple looks strange.
If we added a
variant:prefix that would all still work in the cli. For VS Code there isn't anywhere you could choose to run one specific variant though, so clicking the Run/Debug links shown above would have to run all variants (described by the variant` argument).So if we can add a
variant:prefix in the test name, my plan would be to add( \(variant: .*\))?to the end of the regex to match tests with exactly this name, but optionally with that variant suffix:Does this sound reasonable? I can file a PR to add the text and ensure it doesn't break anything.
gspencergoog commentedon Jul 19, 2021
Sounds reasonable to me.
stevemessick commentedon Jul 19, 2021
Filed flutter/flutter-intellij#5650
DanTup commentedon Jul 20, 2021
#86701 has landed in Flutter and Dart-Code/Dart-Code#3482 in the VS Code extension. The combination of these resolves this issue for VS Code (you'll need releases of both for this to start working). IntelliJ doesn't have this issue since its regex is less strict (though flutter/flutter-intellij#5650 will make this more aligned with VS Code's behaviour).
github-actions commentedon Aug 3, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.