Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Dec 3, 2018

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 test since the declarer is already defined.

This also adds an integration test that confirms that the output of flutter run -t works as expected.

@zoechi zoechi added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels Dec 4, 2018
@jonahwilliams jonahwilliams changed the title [WIP] Check if declarer is defined before invoking test methods Run flutter tests through mini test engine when run directly (flutter run -t test_file) Dec 11, 2018
@yjbanov
Copy link
Contributor

yjbanov commented Dec 11, 2018

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.

@jonahwilliams
Copy link
Contributor Author

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.

@yjbanov
Copy link
Contributor

yjbanov commented Dec 11, 2018

lgtm

@jonahwilliams
Copy link
Contributor Author

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
Copy link
Contributor

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...

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@Hixie
Copy link
Contributor

Hixie commented Dec 12, 2018

As we keep reimplementing more and more of the test package, I see less and less reason to bother with it at all...

@jonahwilliams
Copy link
Contributor Author

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.

@jonahwilliams jonahwilliams merged commit f30029b into flutter:master Dec 12, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter run test/widget_test.dart no longer works

5 participants