flutter/flutter
Auf GitHub ansehen(Test cross-imports) Tests should go in the library that they're testing
Open
#177.414 geöffnet am 22. Okt. 2025
P1a: testsc: proposalframeworkgood first issueteam-frameworktriaged-frameworkwaiting for PR to land (fixed)
Repository-Metriken
- Stars
- (176.322 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 7T 7h) (491 gemergte PRs in 30 T)
Beschreibung
Umbrella issue: https://github.com/flutter/flutter/issues/177028 Design doc: https://docs.google.com/document/d/1UHxALQqCbmgjnM1RNV9xE2pK3IGyx-UktGX1D7hYCjs/edit?tab=t.0
Tests should be located in the library whose code they are testing. If a tests needs to test multiple libraries (say, a platform adaptive constructor), then put it in Material. This will help with our general test organization and also help remove a devDependency after Material and Cupertino are decoupled from the framework.
How to fix
- Find a test listed below that is not already fixed (checked) and that does not have a PR already linked.
- Look at the test that references Material/Cupertino and double check whether it would be possible to migrate the test to remove the dependency. I may have made a mistake including it in this issue (maybe it should be in https://github.com/flutter/flutter/issues/177415 instead).
- If I was wrong and the test doesn't need Material/Cupertino, refactor it to remove the dependency instead of moving the test! Otherwise, for any test that is fundamentally is about testing Material/Cupertino, copy it out of its current file and into test/material or test/cupertino.
- Ensure that all such tests have been removed from the file, and then delete the Material/Cupertino import.
- If there are no tests left in the file, delete the file altogether.
- In your PR, reference this issue as "Part of" instead of "Fixes", to avoid it being prematurely closed.
Tests to fix
Located in Widgets, imported Material
- https://github.com/flutter/flutter/pull/181722
- test/widgets/semantics_debugger_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/routes_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement and Convenience
- test/widgets/sliver_main_axis_group_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement and Convenience
- Button
- test/widgets/sliver_appbar_opacity_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- Could be a bigger refactor could fix it.
- https://github.com/flutter/flutter/pull/184798
- test/widgets/page_route_builder_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/tap_region_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/181266
- test/widgets/heroes_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/decorated_sliver_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/navigator_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/sliver_semantics_test.dart
- Awaiting PR from @navaronbracke
- Located in Widgets, imported Material.
- Category: Misplacement
- Note that there is also sliversemantics_test.dart, also misplaced.
- https://github.com/flutter/flutter/pull/184776
- navigator_on_did_remove_page_test
- test/widgets/navigator_on_did_remove_page_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/editable_text_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- Among others problems. Big test
- https://github.com/flutter/flutter/pull/182546
- test/widgets/scrollable_in_overlay_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/autofill_group_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/scrollbar_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- Only one test out of many in the file uses Material I think.
- test/widgets/scrollable_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/text_selection_toolbar_utils.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/two_dimensional_viewport_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/semantics_role_checks_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/routes_transition_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/scrollable_semantics_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/181469
- test/widgets/slivers_appbar_floating_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/scrollable_selection_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/scrollable_restoration_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/sliver_fill_remaining_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/nested_scroll_view_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/selectable_text_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/181469
- test/widgets/slivers_appbar_floating_pinned_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/184798
- test/widgets/text_selection_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/184798
- test/widgets/radio_group_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/inherited_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/html_element_view_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/drawer_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/page_transitions_builder_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/implicit_animations_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/181268
- test/widgets/scroll_view_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/navigator_replacement_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/sliversemantics_test.dart
- Awaiting PR from @navaronbracke
- Located in Widgets, imported Material.
- Category: Misplacement
- Note that there is also sliver_semantics_test.dart, also misplaced.
- test/widgets/form_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/181469
- test/widgets/slivers_appbar_stretch_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- https://github.com/flutter/flutter/pull/181620
- test/widgets/framework_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
- test/widgets/autocomplete_test.dart
- Located in Widgets, imported Material.
- Category: Misplacement
Located in Cupertino, imported Material
- test/cupertino/colors_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
- test/cupertino/picker_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
- test/cupertino/app_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
- test/cupertino/form_row_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
- test/cupertino/text_selection_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
- test/cupertino/sheet_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
- test/cupertino/date_picker_test.dart
- Located in Cupertino, imported Material.
- Category: Misplacement
Located in Widgets, imported Cupertino
- test/widgets/routes_test.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement
- test/widgets/text_selection_toolbar_utils.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement
- Probably move to Cupertino and import from Material when needed for cross platform.
- test/widgets/editable_text_test.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement
- Quite a lot here.
- test/widgets/selectable_text_test.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement
- test/widgets/widget_inspector_test.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement
- test/widgets/heroes_test.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement
- test/widgets/live_text_utils.dart
- Located in Widgets, imported Cupertino.
- Category: Misplacement