Skip to content

Debugging flutter tests fail if the descrription string has an interpolated value and a is composed of two concatenated strings #4250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #4021
WorikQCI opened this issue Nov 6, 2022 · 5 comments · Fixed by #4487
Labels
in testing Relates to test execution of Dart/Flutter tests for end users is bug
Milestone

Comments

@WorikQCI
Copy link

WorikQCI commented Nov 6, 2022

Describe the bug
If the description of the test has an interpolated value and a is composed of two concatenated strings the test will not run

To Reproduce

Write a test like the following and try to run it by clicking the debug option

image

import 'package:test/test.dart';

void main() async {
  //
  int foo = 1;
  test("Start string $foo " "  end string", () async {
    expect(true, true);
  });
}

Get this result:

Connecting to VM Service at http://127.0.0.1:64510/Y0ktArhJg9g=/ws
No tests match regular expression "^Start string .* " "  end string( \(variant: .*\))?$".
Exited (1)

Expected behavior

I expect the test to run.

Please complete the following information:

  • Operating System and version:
    MacOS 12.6
  • VS Code version:
Version: 1.72.2 (Universal)
Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
Date: 2022-10-12T22:16:30.254Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: No
  • Dart extension version:
    v3.52.1

  • Dart/Flutter SDK version:
    Dart SDK version: 2.18.4 (stable) (Tue Nov 1 15:15:07 2022 +0000) on "macos_arm64"

  • Target device (if the issue relates to Flutter debugging):

@WorikQCI WorikQCI added the is bug label Nov 6, 2022
@DanTup DanTup added this to the v3.54.0 milestone Nov 7, 2022
@DanTup DanTup added in testing Relates to test execution of Dart/Flutter tests for end users and removed is bug in testing Relates to test execution of Dart/Flutter tests for end users labels Nov 7, 2022
@DanTup
Copy link
Member

DanTup commented Nov 7, 2022

Merging this into #4021 since that should fix a number of issues with non-trivial test names like this one.

@DanTup
Copy link
Member

DanTup commented Apr 18, 2023

Re-opening this for tracking to ensure this issue is fixed by the upcoming support for running tests by lines.

@DanTup DanTup reopened this Apr 18, 2023
@DanTup DanTup added this to the v3.64.0 milestone Apr 18, 2023
@DanTup DanTup added is bug in testing Relates to test execution of Dart/Flutter tests for end users and removed duplicate labels Apr 18, 2023
@DanTup
Copy link
Member

DanTup commented Apr 19, 2023

In the next release (and the pre-release version just pushed today - v3.63.20240419), you can choose to have tests executed using their line numbers rather than their names. This fixes a number of issues including this one, caused by not always being able to statically compute the exact name of a test.

Test Invocation settings

Please let me know if you find any issues with this functionality!

@WorikQCI
Copy link
Author

I have been away from VSCode so I have not been paying attention.

One obvious solution is to insist that test names are static.

IMO it is bad practice to put dynamic data there, and I no longer d it. The test should have the same name each time it is run.

I hope this makes sense, as I say I am away from VSCode so you do not have my full attention!

thank you for all your work!

@DanTup
Copy link
Member

DanTup commented Apr 20, 2023

One obvious solution is to insist that test names are static.
IMO it is bad practice to put dynamic data there

Yeah, I think there has been discussion about a lint to enforce this. But there are a lot of tests out there today that do it and I don't think the test runner here should just be broken. There were a bunch of other related issues (not strictly about using variables in names, but just using some helper/wrapper functions that made it difficult to run tests) and the fix for them all was the same so it was worth handling :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in testing Relates to test execution of Dart/Flutter tests for end users is bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants