gpt4 book ai didi

ios - flutter 驱动程序 : Flutter Driver extension is taking a long time to become available

转载 作者:行者123 更新时间:2023-12-03 11:17:03 29 4
gpt4 key购买 nike

我正在尝试按照网页中提供的说明运行 flutter 集成测试:https://flutter.dev/docs/cookbook/testing/integration/introduction但是当尝试使用 iOS 设备执行时,它总是因 flutterdriver 超时而失败,但是如果我使用 android 设备执行同一段代码,它会成功运行。

执行的命令是:

flutter driver --target=test_driver/app.dart

并且(仅在 iOS 中),显示的错误如下:
...
flutter: Observatory listening on http://127.0.0.1:49605/Jh_J7boSKBk=/
Installing and launching... 22.5s
[info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:1043/Jh_J7boSKBk=/
[trace] FlutterDriver: Isolate found with number: 589047572
[trace] FlutterDriver: Isolate is paused at start.
[trace] FlutterDriver: Attempting to resume isolate
[trace] FlutterDriver: Waiting for service extension
flutter: main dev
[warning] FlutterDriver: Flutter Driver extension is taking a long time to become available. Ensure your test app (often "lib/main.dart") imports "package:flutter_driver/driver_extension.dart" and calls enableFlutterDriverExtension() as the first call in main().

看起来当它在iOS中执行时,它完全忽略了指定的目标,并试图直接运行lib/main.dart文件,但是,为什么?

我对以下网页说明的意思是使用 2 个文件进行测试:
test_driver/app.dart 和 test_driver/app_test.dart

test_driver/app.dart
import 'package:flutter_driver/driver_extension.dart';
import 'package:my_app/main.dart' as app;

void main() async {
// This line enables the extension
await enableFlutterDriverExtension();

// Call the `main()` function of your app or call `runApp` with any widget you
// are interested in testing.
await app.main();
}

test_driver/app_test.dart
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
group('end-to-end test', () {
FlutterDriver driver;

setUpAll(() async {
// Connect to a running Flutter application instance.
driver = await FlutterDriver.connect();
});

tearDownAll(() async {
if (driver != null)
driver.close();
});

test('whatever', () async {
//whatever
});
});
}

正如这里评论的那样: #17184 ,它可以通过在 main.dart 中引入 enableFlutterDriverExtension() 来修复,但我宁愿不在应用程序代码中编写任何额外的内容。

有没有可能使用另一种方法修复它?

谢谢

最佳答案

我已按照 docs for writing integration tests 上的步骤操作它在 Flutter stable(版本 1.22.5)和 master(版本 1.26.0-2.0.pre.281) channel 上都可以正常工作。而命令中的docs演示 flutter drive 的使用, 使用 flutter driver在我的测试中似乎也运行良好。
撇开这一点,即使我无法在本地复制该问题,似乎该问题已通过遵循 GitHub issue thread 中提到的解决方法得到解决。每检查评论。

关于ios - flutter 驱动程序 : Flutter Driver extension is taking a long time to become available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56489067/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com