-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Run flutter tests through mini test engine when run directly (flutter run -t test_file) #24930
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
Conversation
|
Is there a reason why this needs to run in the devicelab? It does not seem to need any devices, so could run in Cirrus? LGTM otherwise. |
|
This specifically verifies that flutter run -t test_file works, running a test via flutter test will go through the old paths since the declarer will be defined. |
|
cc @Hixie |
| import 'package:test_api/src/backend/runtime.dart'; // ignore: implementation_imports | ||
| import 'package:test_api/src/backend/message.dart'; // ignore: implementation_imports | ||
| import 'package:test_api/src/backend/invoker.dart'; // ignore: implementation_imports | ||
| import 'package:test_api/src/backend/state.dart'; // ignore: implementation_imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this is going to cost us a lot in technical debt...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a flaw in the test_api package. How are we supposed to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These APIs are stable but haven't been formally made public yet. I've opened dart-lang/test#962 to track, but most of these could be moved to lib.
|
As we keep reimplementing more and more of the test package, I see less and less reason to bother with it at all... |
|
Fundamentally, test_api is a package to let you build your own test framework - but importantly it does so in a way that lets us be compatible with existing tests, mockito, matcher, et cetera. |

Fixes #24650
If Declarer is not defined, we need to set up our own mini-engine to execute flutter tests and log messages. Instead of adding a dep on test_core, we duplicate a subset of the functionality needed for flutter run test. To intercept all of the calls, we hide test, group, setUp, setUpAll, tearDown, tearDownAll and re-export the same methods.
This code does not run when tests are executed via
flutter testsince the declarer is already defined.This also adds an integration test that confirms that the output of flutter run -t works as expected.