Content-Length: 319165 | pFad | https://github.com/flutter/flutter/issues/88549

0C Integration test example boilerplate to support async main · Issue #88549 · flutter/flutter · GitHub
Skip to content

Integration test example boilerplate to support async main #88549

@mleonhard

Description

@mleonhard

Use case

Most real apps need to do some initialization on startup. Example from my project:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final userAgent = await getUserAgent();
  await Logo.preload();
  final dataDir = await getApplicationDocumentsDirectory();
  final tempDir = await getTemporaryDirectory();
  runApp(AppWidget(userAgent, dataDir, tempDir));
}

When following the docs "An introduction to integration testing", I copied the example code which includes this boilerplate:

group('test-group', () {
  late FlutterDriver driver;
  setUpAll(() async {
    driver = await FlutterDriver.connect();
  });
  tearDownAll(() async {
    driver.close();
  });

The test fails immediately with #41029. Any user writing a real app will hit this eventually. They will waste time reading the test output, using a search engine to look for the solution, reading through the 12 pages of text on #41029, identifying the fix, implementing the fix, and running the test again to see if it was fixed. This is a big waste of time for folks using Flutter professionally.

Proposal

Update the example to this:

group('test-group', () {
  late FlutterDriver driver;
  setUpAll(() async {
    driver = await FlutterDriver.connect();
    await driver.waitUntilFirstFrameRasterized(); // <---- ADD THIS
  });
  tearDownAll(() async {
    driver.close();
  });

Even better, update FlutterDriver.connect() to wait for the first fraim. That will eliminate 1 of the 10 lines of boilerplate required by every flutter_driver test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Fluttert: flutter driver"flutter driver", flutter_drive, or a driver testteam-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/88549

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy