Skip to content

Produce a warning if multiple tests run with the exact same group/test name #1571

@DanTup

Description

@DanTup

There's some functionality in Dart-Code that tries to handle this, but it's a rather clunky and I think could be better dealt with here. (I'm not certain it's a common issue, but it did come up for Dart-Code at least once).

Consider a user duplicated a test, but forgot to update the name:

main() {
group('foo', () {
test('bar', () {});
test('bar', () {});
});

Since IDEs can only run tests by name, it can be confusing to click Run next to one test and find yourself debugging code that originated from the other.

Unless there's a good reason to support multiple tests with the same name, it would be nice if the test package could warn when this happens (or even just refuse to run). If it's opt-in with a flag, that would be fine too (the IDE could pass it in the case where it expects exactly one test to run - eg. "Run" is clicked on a test, and not a group).

Another possibility could be to detect this before running with a lint or something (although dynamic test names might complicate that a little)? @pq

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-breaking-releaseIssues that are worth doing but need to wait for a breaking version bump

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions