Flutter Driver 在闪屏处挂起

Flutter Driver hangs at splash screen

我正在尝试为我的应用程序和应用程序设置 Flutter Driver 测试 运行s async 所以我发现 https://github.com/flutter/flutter/issues/41029 说你需要做的就是添加 await driver.waitUntilFirstFrameRasterized(); 和它应该有效,虽然这确实阻止了测试失败,但 nos 根本没有 运行.

应用程序只是挂在初始屏幕上,甚至从未进入应用程序本身。

据我所知,为了测试 运行

,我只需要设置这些
  FlutterDriver driver;
  // Connect to the Flutter driver before running any tests.
  setUpAll(() async {
    driver = await FlutterDriver.connect();
    await driver.waitUntilFirstFrameRasterized();

    // await Directory('screenshots').create();
  });

  // Close the connection to the driver after the tests have completed.
  tearDownAll(() async {
    if (driver != null) {
      await driver.close();
    }
  });

但是,我在终端中得到的只是以下输出:

VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:54264/tt9kN4jBSrc=/
VMServiceFlutterDriver: Isolate found with number: 2942164624858163
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
VMServiceFlutterDriver: Connected to Flutter application.
VMServiceFlutterDriver: waitForCondition message is taking a long time to complete...

我已经离开它几分钟但没有任何反应,我已经禁用了 firebase 初始化,以防万一它被阻止,因为我需要接受警报对话,而不是我什至可以看到那么远.

原来我还需要使用 IsolatesWorkaround

  FlutterDriver driver;
  IsolatesWorkaround workaround;
  // Connect to the Flutter driver before running any tests.
  setUpAll(() async {
    driver = await FlutterDriver.connect();
    workaround = IsolatesWorkaround(driver);
    await workaround.resumeIsolates();
    await driver.waitUntilFirstFrameRasterized();

    if (!await Directory('screenshots').exists()) {
      await Directory('screenshots').create();
    }
  });

  // Close the connection to the driver after the tests have completed.
  tearDownAll(() async {
    await driver?.close();
    await workaround.tearDown();
  });

参见:https://gist.github.com/vishna/03c5d5e8eb14c5e567256782cddce8b4