You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
flutter run test/widget_test.dart no longer works #24650
(I discussed this with @jonahwilliams already, but I'm filing this to make sure we're tracking it.)
flutter run test/widget_test.dart is broken after the recent test_api changes. Attempting it will hit various runtime exceptions such as:
NoSuchMethodError: The method 'test' was called on null.
NoSuchMethodError: The method 'setUp' was called on null.
NoSuchMethodError: The method 'tearDown' was called on null.
Correct. The difference is the group method exposed by package test includes fallback logic to allow self-invoking tests. This also includes a larger set of dependencies, and isn't useful for "regular" flutter tests.
Highly technical explanation:
group(...) {
if (someEnvNotSetup) {
setUpEnv();
}
real.group(...);
}
We could get around this by running the flutter run testfile through a test entry-point like we do for normal flutter tests. This might require an additional flag or separate command, or it might not if setting up the test env has no side effects for a normal debug mode flutter run
group/test and friends require a Declarer to set themselves up. This manages the current state of the tests and handles communication with the command line/tracks outstanding callbacks and such
I think the solution is for flutter_test to provide the same capability as package:test, namely to handle setting up the Declarer when there isn't one in the current zone.
Update: I've found that it is possible to restore the ability to run tests directly without increasing dependency count or modifying the entrypoints. Working this into a small PR in the next few days
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
jonahwilliams commentedon Nov 23, 2018
I'll put together documentation on how to make this work. In general:
zoechi commentedon Nov 26, 2018
What is the reasoning behind that.
Does
groupfromflutter_testnot work when run on a device withflutter run?jonahwilliams commentedon Nov 26, 2018
Correct. The difference is the
groupmethod exposed by package test includes fallback logic to allow self-invoking tests. This also includes a larger set of dependencies, and isn't useful for "regular" flutter tests.Highly technical explanation:
We could get around this by running the
flutter run testfilethrough a test entry-point like we do for normal flutter tests. This might require an additional flag or separate command, or it might not if setting up the test env has no side effects for a normal debug mode flutter runzoechi commentedon Nov 26, 2018
I think it's worth investigating to find a way so that imports don't need to be changed between
flutter runandflutter testruns.jonahwilliams commentedon Nov 26, 2018
agreed. I think the problem isn't so much the imports, but that the solution is completely unintuitive.
Hixie commentedon Nov 28, 2018
Why can't we just run the callbacks directly? I don't understand what needs to be set up.
Hixie commentedon Nov 28, 2018
(I mean, in test_api, why can't
group('', foo)just callfoo(), at least if there's no test framework loaded.)jonahwilliams commentedon Nov 28, 2018
group/test and friends require a Declarer to set themselves up. This manages the current state of the tests and handles communication with the command line/tracks outstanding callbacks and such
I think the solution is for
flutter_testto provide the same capability as package:test, namely to handle setting up the Declarer when there isn't one in the current zone.jonahwilliams commentedon Dec 2, 2018
Update: I've found that it is possible to restore the ability to run tests directly without increasing dependency count or modifying the entrypoints. Working this into a small PR in the next few days
github-actions commentedon Aug 14, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.