Skip to content

Should two tests with the same name be an error? #661

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
skybrian opened this issue Jun 30, 2017 · 3 comments
Closed

Should two tests with the same name be an error? #661

skybrian opened this issue Jun 30, 2017 · 3 comments

Comments

@skybrian
Copy link

In the Dart and (soon) Flutter plugins for IDEA, we use --name and --plain-name to identify a test to run within a test file. Some folks on the Flutter team are concerned that users might accidentally write two tests with the same name. Could package:test check for this?

Followup to discussion in:
flutter/flutter#11020

@nex3
Copy link
Member

nex3 commented Jun 30, 2017

There are a number of issues with this. --name works across multiple test suites, and coordinating this restriction across those suites (which may be loaded in parallel, and likely won't all be in memory at the same time) will be difficult. Also, it may be totally reasonable to use the same test name in different contexts—for example, you may well have a test named "toString()" in both widget_test.dart and gadget_test.dart.

Maybe the biggest problem, though, is that this would be a breaking change and we try hard to avoid those in test. We could potentially do this when we bump the version to 1.0.0, but it would be an extra compatibility hurdle that would add friction to the upgrade process.

Hopefully when #48 lands it'll be pretty easy to add some sort of linter for this for users who want this restriction.

@nex3 nex3 closed this as completed Jun 30, 2017
@skybrian
Copy link
Author

Okay, thanks!

Just to clarify, I think the Flutter team would only be concerned about uniqueness within a single test file. That is, (filename, test name) could serve as a unique id, since in IDEA, we'd only use this to run tests within one file at a time.

@nex3
Copy link
Member

nex3 commented Jun 30, 2017

I can definitely see how that would make sense for their use-case! But from the perspective of test as a whole, we thing about test name selections as a cross-file concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants