Run flutter tests through mini test engine when run directly (flutter run -t test_file)#24930
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.
well this is going to cost us a lot in technical debt...
There was a problem hiding this comment.
this seems like a flaw in the test_api package. How are we supposed to do this?
There was a problem hiding this comment.
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.