Skip to content

"No tests match regular expression ..." when running tests in reusable test suite functions #5707

@christerswahn

Description

@christerswahn

Describe the bug
When running a group or a test (via clicking 'run' or 'debug' on the group / test) in VSCode, and those groups / tests are defined in a reusable test suite function, the test is not run and this error message is presented:

For group:

No tests match regular expression "^With id value 42".

For test:

No tests match regular expression "^With id value 42 when someOperation is called then 2 is returned( \(variant: .*\))?$".

The technical problem is that the regex prefix ^ is being added. I'm not aware of the reason for it to exist in the first place, but given that writing reusable test suite functions should at least be somewhat common, at the very least it should be possible to disable - either in settings or via some mechanism in the test source file.

For context, the use case we have is contract tests: The same tests are run against real world API clients as well as against our mocks of them. See the repro example below.

See also:

#1458 - which addressed the $ at the end of the regex, but not the ^ at the start.

To Reproduce
Steps to reproduce the behavior:

Copy this code into a _test.dart file in VSCode:

import 'package:test/test.dart';

void main() async {
  group('Mock -', () {
    testSuite(MockBillingClient());
  });

  group('Real -', () {
    testSuite(RealBillingClient());
  });
}

void testSuite(final BillingClient client) {
  group('With id value 42', () {
    test('when someOperation is called then 2 is returned', () async {
      await expectLater(client.someOperation('42'), completion(equals(2)));
    });
  });
}

abstract interface class BillingClient {
  Future<int> someOperation(final String id);
}

class MockBillingClient implements BillingClient {
  @override
  Future<int> someOperation(final String id) async {
    return id.length;
  }
}

class RealBillingClient implements BillingClient {
  @override
  Future<int> someOperation(final String id) async {
    return id.length;
  }
}

Expected behavior

The group / test should run.

This would probably require the regular expression for running the test not to begin with ^.

Please complete the following information:

Dart Code extension: 3.118.1
Flutter extension: 3.118.0 (activated)

App: Cursor
App Host: desktop
Version: mac 1.99.3

Workspace type: Dart, Flutter (LSP)

  • Dart 3.9.2 (stable) (Wed Aug 27 03:49:40 2025 -0700) on "macos_arm64"
  • on macos / Version 15.6.1 (Build 24G90)
  • locale is en-US

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