Skip to content

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

Closed

Description

@WorikQCI

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):

Activity

  1. added this to the v3.54.0 milestone on Nov 7, 2022
  2. added
    in testingRelates to test execution of Dart/Flutter tests for end users
    and removed
    in testingRelates to test execution of Dart/Flutter tests for end users
    on Nov 7, 2022
  3. DanTup commented on Nov 7, 2022

    @DanTup
    Member

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

  4. removed this from the v3.54.0 milestone on Nov 7, 2022
  5. DanTup commented on Apr 18, 2023

    @DanTup
    Member

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

  6. reopened this on Apr 18, 2023
  7. added this to the v3.64.0 milestone on Apr 18, 2023
  8. added
    in testingRelates to test execution of Dart/Flutter tests for end users
    and removed on Apr 18, 2023
  9. DanTup commented on Apr 19, 2023

    @DanTup
    Member

    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!

  10. WorikQCI commented on Apr 19, 2023

    @WorikQCI
    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!

  11. DanTup commented on Apr 20, 2023

    @DanTup
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in testingRelates to test execution of Dart/Flutter tests for end usersis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions