Flutter开发HarmonyOS鸿蒙Next应用的时候flutter_flutter 3.7.12创建的demo工程测试UITest无法运行
Flutter开发HarmonyOS鸿蒙Next应用的时候flutter_flutter 3.7.12创建的demo工程测试UITest无法运行
【任务描述】
- flutter_flutter 3.7.12创建的demo工程测试Ut失败
详细日志
xxx ohos_example % flutter test .
00:00 +0: loading /Users/QXZ3LN7/project/ohos_example/./test/widget_test.dart Shell: [INFO:dart_snapshot.cc(60)] SearchMapping file:
Shell: [INFO:dart_snapshot.cc(60)] SearchMapping file:
Shell: [INFO:dart_snapshot.cc(60)] SearchMapping file:
Shell: [INFO:dart_snapshot.cc(60)] SearchMapping file:
Shell: [INFO:platform_view.cc(18)] PlatformView
Shell: [WARNING:flutter/shell/common/platform_view.cc(24)] This platform does not provide a Vsync waiter implementation. A simple timer based fallback is being used.
Shell: [WARNING:flutter/shell/common/platform_view.cc(91)] This platform does not set up the resource context on the IO thread for async texture uploads.
Shell: [WARNING:flutter/shell/common/shell_io_manager.cc(57)] The IO manager was initialized without a resource context. Async texture uploads will be disabled. Expect performance degradation.
Shell: [WARNING:flutter/shell/common/platform_view.cc(91)] This platform does not set up the resource context on the IO thread for async texture uploads.
00:01 +0: Counter increments smoke test unhandled error during finalization of test:
/Users/QXZ3LN7/project/ohos_example/./test/widget_test.dart
TestDeviceException(Shell subprocess crashed with segmentation fault.)
#0 FlutterTesterTestDevice.finished (package:flutter_tools/src/test/flutter_tester_device.dart:232:5)
<asynchronous suspension>
#1 FlutterTesterTestDevice.kill (package:flutter_tools/src/test/flutter_tester_device.dart:214:5)
<asynchronous suspension>
#2 FlutterPlatform._startTest.<anonymous closure> (package:flutter_tools/src/test/flutter_platform.dart:506:9)
<asynchronous suspension>
#3 FlutterPlatform._startTest (package:flutter_tools/src/test/flutter_platform.dart:562:11)
<asynchronous suspension>
00:01 +0: Counter increments smoke test - did not complete [E]
00:01 +0: Some tests failed.
No tests were found.
xxx ohos_example % flutter --version
Flutter 3.7.12-ohos • channel unknown • unknown source
Framework • revision aa3b0ede0f (8 weeks ago) • 2024-06-05 15:34:58 +0000
Engine • revision 1a65d409c7
Tools • Dart 2.19.6 • DevTools 2.20.1
指定platform和不指定platform都报错 testWidgets(‘Counter increments smoke test’, (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.ohos; // Build our app and trigger a frame. await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
【解决方案】
无
【任务来源】
社区
直接pump一个空的Container也会报这个错误
flutter clean
和重启电脑测试依然出现此错误
在Flutter开发HarmonyOS鸿蒙Next应用时,如果遇到使用flutter_flutter 3.7.12版本创建的demo工程中的UITest无法运行的问题,可能是由于以下几个常见原因导致的:
-
环境配置问题:确保你的开发环境已经正确配置了Flutter SDK、Dart SDK以及HarmonyOS的开发工具包。同时,检查环境变量设置是否正确,包括PATH和FLUTTER_HOME等。
-
依赖冲突:检查项目中是否存在与UITest相关的依赖冲突。可以尝试更新或降级相关依赖包,或者清理并重新获取依赖。
-
测试代码问题:检查UITest的测试代码是否正确编写,包括测试用例的注解、断言以及测试框架的使用是否符合HarmonyOS的测试规范。
-
设备兼容性问题:确保你用于运行UITest的设备或模拟器已经正确配置,并且支持运行HarmonyOS应用。
-
权限问题:检查应用是否有足够的权限来执行测试,特别是在涉及系统级功能或访问敏感数据时。
如果以上检查均无误但问题依旧存在,可能是由于更深层次的技术问题或特定于你项目的问题。此时,建议直接联系官网客服获取更专业的帮助。官网地址是:https://www.itying.com/category-93-b0.html