#flutter #testing #integration-testing #flutter-integration-test
Вопрос:
Я пытаюсь запустить/настроить интеграционный тест. Я гуглю возвращенный ответ, но не могу понять, что не так.
У меня есть: 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 buildappoutputsflutter-apkapp-prod-debug.apk.
Installing buildappoutputsflutter-apkapp.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>
From what I understand it’s trying to connect to a local port but I can’t figure out why as web is not enabled for this project.
UPDATE
This is the error, but it’s not descriptive enough to tell me where in the code this is happening.
Из того, что я видел, это такая строка: Расширение requestData не зарегистрировано
Это связано с тем, что драйверы интеграции не настроены или, возможно, не работают из-за асинхронности. Я осмотрелся и пока не нашел никакого решения.