颤振驱动程序挂在启动画面
Posted
技术标签:
【中文标题】颤振驱动程序挂在启动画面【英文标题】:Flutter Driver hangs at splash screen 【发布时间】:2021-02-24 02:24:44 【问题描述】:我正在尝试为我的应用程序设置 Flutter 驱动程序测试,并且应用程序运行异步,所以我发现 https://github.com/flutter/flutter/issues/41029
说你需要做的就是添加 await driver.waitUntilFirstFrameRasterized();
并且它应该可以工作,而这确实可以阻止测试失败它根本不运行。
应用程序只是挂在启动屏幕上,甚至从未进入应用程序本身。
据我了解,这就是我需要进行的所有设置才能运行测试
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 初始化,以防它被阻止,因为我需要接受警报对话,而不是我什至能看到这么远。
【问题讨论】:
【参考方案1】:原来我也需要使用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
【讨论】:
flutter 2的任何解决方案? @Mattias 这一切都过时了,去年 12 月出现了一个新的集成测试框架,我认为它模仿了flutter_test,“integration_test_driver”,超级简单,我认为也快了 10 倍 经过更多研究,我也得出了这个结论。对于任何因阅读旧文档而失去灵魂的人,截至目前,帮助我驱动应用程序和执行测试的软件包是:flutter_test、integration_test 和 flutter_driver。具体驱动:integration_test/integration_test_driver.dart。以上是关于颤振驱动程序挂在启动画面的主要内容,如果未能解决你的问题,请参考以下文章