首页 > 解决方案 > 无法从 Flutter 集成测试响应中找出问题所在

问题描述

我正在尝试运行/设置集成测试。我正在谷歌搜索返回的响应,但我不知道出了什么问题。

我有:一个integration_test包含文件的文件夹app_test.dart

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets("failing test example", (WidgetTester tester) async {
    expect(2 + 2, equals(5));
  });
}

包含test_driver文件的文件夹integration_test.dart


Future<void> main() => integrationDriver();

包含test文件的文件夹widget_test.dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
  test("This is a sample UNIT test", () {
    print("This is a UNIT test");
  });

  testWidgets('This is a sample WIDGET test', (WidgetTester tester) async {
    print("This is from the WIDGET test function 1");
    await print("This is from the WIDGET test function 2");
    print("This is from the WIDGET test function 3");
  });
}

由于我的口味,这是我用来运行我的集成测试的:

flutter drive \ --driver=test_driver/integration_test.dart \ --target=integration_test/app_test.dart --flavor prod -t lib/main_prod.dart

我得到以下回复:

Running "flutter pub get" in medical-app-frontend...                5.8s
Running Gradle task 'assembleProdDebug'...                         65.6s
√  Built build\app\outputs\flutter-apk\app-prod-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...                13.9s
D/HostConnection(16237): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem
ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements    
ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8     
ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing
ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0
W/OpenGLRenderer(16237): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/EGL_emulation(16237): eglCreateContext: 0xf6b61bf0: maj 3 min 0 rcv 3
D/EGL_emulation(16237): eglMakeCurrent: 0xf6b61bf0: ver 3 0 (tinfo 0xf6e9d130)
D/HostConnection(16237): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem
ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements    
ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8     
ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing
ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0
D/HostConnection(16237): HostConnection::get() New Host Connection established 0xf6d55370, tid 16304
D/HostConnection(16237): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem
ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements    
ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8     
ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing
ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0
D/EGL_emulation(16237): eglMakeCurrent: 0xf6b41dd0: ver 3 0 (tinfo 0xf6ebc790)
D/EGL_emulation(16237): eglCreateContext: 0xf6b62bb0: maj 3 min 0 rcv 3
D/EGL_emulation(16237): eglMakeCurrent: 0xf6b62bb0: ver 3 0 (tinfo 0xf6ebc790)
D/EGL_emulation(16237): eglMakeCurrent: 0xf6b41dd0: ver 3 0 (tinfo 0xf6ebc790)
VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:64088/wz5l9PDpPCY=/
D/EGL_emulation(16237): eglMakeCurrent: 0xf6b41dd0: ver 3 0 (tinfo 0xf6ebc790)
D/EGL_emulation(16237): eglMakeCurrent: 0xf6b61bf0: ver 3 0 (tinfo 0xf6e9d130)
VMServiceFlutterDriver: Isolate found with number: 1014490864547079
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
I/Choreographer(16237): Skipped 161 frames!  The application may be doing too much work on its main thread.
E/FirebaseMessaging(16237): Topic sync or token retrieval failed on hard failure exceptions: java.util.concurrent.ExecutionException: java.io.IOException: FIS_AUTH_ERROR. Won't retry the operation.
W/SoundPool(16237): Use of stream types is deprecated for operations other than volume control
W/SoundPool(16237): See the documentation of SoundPool() for what to use instead with android.media.AudioAttributes to qualify your playback use case
W/Glide   (16237): Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated
AppGlideModule implementation or LibraryGlideModules will be silently ignored
W/com.skinopathy(16237): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, reflection, allowed)
W/com.skinopathy(16237): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
W/com.skinopathy(16237): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
W/Intercom realtime(16237): No realtime endpoints present so we can't connect
I/OMXClient(16237): IOmx service obtained
I/OMXClient(16237): IOmx service obtained
I/OMXClient(16237): IOmx service obtained
I/OMXClient(16237): IOmx service obtained
I/flutter (16237): AppRequestState()
I/flutter (16237): Transition { currentState: AppInitial(), event: AppRequestState(), nextState: AppSignIn() }
VMServiceFlutterDriver: Connected to Flutter application.
Unhandled exception:
FormatException: Unexpected character (at character 1)
No requestData Extension registered
^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1405:5)
#1      _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1272:9)
#2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:937:22)
#3      _parseJson (dart:convert-patch/convert_patch.dart:40:10)
#4      JsonDecoder.convert (dart:convert/json.dart:506:36)
#5      JsonCodec.decode (dart:convert/json.dart:157:41)
#6      Response.fromJson (package:integration_test/common.dart:45:52)
#7      integrationDriver (package:integration_test/integration_test_driver.dart:72:38)
<asynchronous suspension>

据我了解,它正在尝试连接到本地端口,但我无法弄清楚为什么该项目没有启用网络。

更新

这是错误,但它的描述性不足以告诉我代码中发生这种情况的位置。

在此处输入图像描述

从我所见,这是这一行: 没有注册请求数据扩展

它与未设置集成驱动程序或由于异步而可能无法工作有关。我环顾四周,我还没有遇到任何解决方案。

标签: fluttertestingintegration-testingflutter-integration-test

解决方案


推荐阅读