Content-Length: 288359 | pFad | https://github.com/flutter/flutter/issues/132591

95 Tool: Consolidate test-only code into the test/ folder, per-test if able · Issue #132591 · flutter/flutter · GitHub
Skip to content

Tool: Consolidate test-only code into the test/ folder, per-test if able #132591

@matanlurey

Description

@matanlurey

In #132346, @reidbaker suggested added a @visibleForTesting annotation to Artifact:

factory Artifacts.test({String? localEngine, FileSystem? fileSystem})

It wasn't as easy as expected, because it's also used by IMobileDevice:

factory IMobileDevice.test({ required ProcessManager processManager }) {
  return IMobileDevice(
    artifacts: Artifacts.test(),
    cache: Cache.test(processManager: processManager),
    processManager: processManager,
    logger: BufferLogger.test(),
  );
}

After discussing with @christopherfujino on Discord:

yeah, i don't know the history, but i suspect that's the origen of the [Class].test() factories. For Artifacts.test() in particular, it references a private function, so that function will have to be made @visibleForTesting.

So, we have a fakes.dart file under test/, however, a lot of those are hard-coded to specific behavior, or have tons of configuration constructor parameters. Thus, at least for myself, when I need a new test type, I don't default to importing that library and trying to re-use. I'm not sure the right way to organize things so that we have good discoverability of general purpose test constructors.

maybe the answer is to migrate those classes under fakes.dart that are pretty specific to a specific set of tests just to the test library that uses it

So, in other words:

  • Migrate classes in fakes.dart that are only used by a specific test(s) to those tests
  • Move general testing utilities in lib/** to test/fakes.dart
  • Consider updating documentation so folks have a chance in finding out how fakes should be setup in the tool

(I'm happy to contribute here, but it might take some time for this to rise to the top of the stack)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: tech-debtTechnical debt, code quality, testing, etc.team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/flutter/flutter/issues/132591

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy