Skip to content

Refactor scrollable_semantics_test.dart to avoid shared top-level SemanticsTester #189799

Closed

Description

@mbcorona

What needs cleaning up

packages/flutter/test/widgets/scrollable_semantics_test.dart keeps a single SemanticsTester in a top-level variable that is reused across every test in the file:

void main() {
  late SemanticsTester semantics;
  ...
}

Sharing one tester across tests is fragile. If a test doesn't dispose of it (for example, when a test fails partway through), that state can leak into the next test and produce confusing, order-dependent failures.

What to do

Refactor the file so each test owns its own SemanticsTester and disposes of it reliably. A setUp/tearDown pair, or addTearDown inside each test, both work well here. After the change there should be no shared top-level SemanticsTester.

Scope

  • Only packages/flutter/test/widgets/scrollable_semantics_test.dart.
  • Test-only change; no framework behavior changes.
  • All existing tests in the file should still pass.

Context

Noticed during review of #188788. It was intentionally left out of that PR to keep it focused on the fix, and tracked here for a separate follow-up.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    f: scrollingViewports, list views, slivers, etc.
    c: tech-debtTechnical debt, code quality, testing, etc.
    on Jul 21, 2026
  2. added a commit that references this issue on Jul 29, 2026
    3656164
  3. self-assigned this
    on Jul 31, 2026
  4. github-actions commented on Aug 14, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: tech-debtTechnical debt, code quality, testing, etc.f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions