dart-lang / dart-lang/test

Provide interfaces that dramatically clean up how Flutter depends on package:test

Open
#798 0 comments 0 reactions 0 assignees View on GitHub
customer-flutter
Dominant language
Dart
Stars
536
Forks
232
Avg merge
1d 10h
Merged PRs (30d)
10

Description

Right now, "flutter test", the flutter test runner that wraps package:test, has to jump through hoops and call private APIs to get package:test to do the right thing for Flutter tests:

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/test.dart
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/test/runner.dart
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/test/flutter_platform.dart

The first command above calls the second, which calls the third (search for "installHook") which hooks in using "registerPlatformPlugin"; then the second calls "main()" in the test package directly. The `PlatformPlugin` implementation we have (`_FlutterPlatform` in the third file above) was a very tricky class to add due to all the asynchrony and race conditions involved in running code that by definition you don't trust to act correctly (as in, the test runner could crash, the websocket we use to talk to the test could die without notice, the test itself could fail in weird ways, etc).

We also support a bunch of features here, like enabling the observatory in tests, starting tests paused, a machine-readable output format for interaction with IDEs, changing how the code is compiled, IPv4 and IPv6 for communicating to the test, detecting crashes after the test has "passed", source code coverage data collection, controlling the rate of subprocess generation (important for test coverage since the process takes a long time to quit after it's "done"; we had to work around package:test here because it doesn't care when the subprocess is done and would start thousands of subprocesses simultaneously), setting environment variables so that we can configure the flutter_test package, etc.

Ideally we would remove all need to say `ignore: implementation_imports` in these files.

Contributor guide

Open the contributing guide

Research direction

Start with packages/flutter_tools/lib/src/commands/test.dart, packages/flutter_tools/lib/src/test/runner.dart, and packages/flutter_tools/lib/src/test/flutter_platform.dart; trace installHook, registerPlatformPlugin, and the direct package:test main() call. Compare the listed Flutter-specific requirements with package:test's public APIs, then document the interface boundaries needed to remove implementation_imports dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
developer-experience, testing, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.