flutter/flutter

(Test cross-imports) Tests should go in the library that they're testing

Open

#177.414 aberto em 22 de out. de 2025

Ver no GitHub
 (5 comments) (1 reaction) (0 assignees)Dart (30.366 forks)batch import
P1a: testsc: proposalframeworkgood first issueteam-frameworktriaged-frameworkwaiting for PR to land (fixed)

Métricas do repositório

Stars
 (176.322 stars)
Métricas de merge de PR
 (Mesclagem média 7d 7h) (491 fundiu PRs em 30d)

Description

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

  1. Find a test listed below that is not already fixed (checked) and that does not have a PR already linked.
  2. 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).
  3. 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.
  4. Ensure that all such tests have been removed from the file, and then delete the Material/Cupertino import.
  5. If there are no tests left in the file, delete the file altogether.
  6. 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

Located in Cupertino, imported Material

Located in Widgets, imported Cupertino

Guia do colaborador