-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add error for empty groups #2012
base: master
Are you sure you want to change the base?
Conversation
Closes #1961 After declaring a group check for declared tests, if there were none add a synthetic test that fails with an error about the empty group.
This does cause some failures in existing tests. @jakemac53 - Do you think we can get away with fixing the google3 impacted tests and releasing this as a non-breaking change? |
I found dart-lang/yaml#145 with this change. |
Cases like this are actually slightly concerning to me - although they should have been using The other thing I was thinking about is when people are creating tests programmatically. You could define a group in an outer loop, and then end up skipping all values in an inner loop, thus not adding any tests to it. If that is an error it becomes potentially quite a pain. |
If we don't have evidence of the programmatic tests being an issue today I think it is probably fine though. |
How many failures are we talking about? |
~150 I looked at a random sample of 10 of them. Three were the programmatic case - a One was a clear mistake, there was a Five were likely mistakes - they had a One was a |
Would it be reasonable to have an |
I could take a look at how much work it would be to implement. |
The output already has special behavior for when there are no tests at all, and the output is less clear when it's the root group which is empty since the root group has no name. Also refactor duplicate name tests to have different file content when testing identical group names to avoid empty groups in any case.
cc @christopherfujino - This is a technically breaking change but we plan on rolling this out without a major version bump. This will also impact the behavior of the |
The empty group will soon become a warning or an error. Eagerly skip the group to avoid any issue when the test runner changes behavior. dart-lang/test#2012 Note that the linked issue has been resolved, and the comment in this group body may be out of date. This change will impact the output from running tests - there will be an indication of the skipped test.
The empty group will soon become a warning or an error. Eagerly skip the group to avoid any issue when the test runner changes behavior. dart-lang/test#2012 Note that the linked issue has been resolved, and the comment in this group body may be out of date. This change will impact the output from running tests - there will be an indication of the skipped test.
I took a look at fixing all the cases in google3, and even the programatic ones were not too difficult to correct, even without an @mosuem also had a good suggestion in a meeting today to only add the error when there is a @jakemac53 - WDYT about allowing completely empty groups, but making an error for the case where there is |
I would be fine with that |
I found at least one pattern for a mistake which the looser restriction lets through: group('some group', defineTests(someConstConfig));
group('another group', () {
var config = someComputedConfig();
defineTests(config);
}); no There are quite a few which still need the |
Wow, that is a nasty API 🤣 . I don't know if I care enough about that to make the TODO case be more noisy. |
The empty group will soon become a warning or an error. Eagerly skip the group to avoid any issue when the test runner changes behavior. dart-lang/test#2012 Note that the linked issue has been resolved, and the comment in this group body may be out of date. This change will impact the output from running tests - there will be an indication of the skipped test.
Closes #1961
After declaring a group check for declared tests, if there were none add
a synthetic test that fails with an error about the empty group.