'!_debugInitialized':运行 flutter 集成测试时不正确

Bhu*_*ney 14 automated-tests flutter flutter-test

我正在尝试运行基本的 flutter 集成测试来调用我的主应用程序小部件,但它失败了。\n我已遵循官方文档 [https://docs.flutter.dev/testing/integration-测试]

\n

这是完整的堆栈跟踪:

\n
Running "flutter pub get" in my_app...              2,651ms\nRunning Gradle task \'assembleStagingDebug\'...                           \nRunning Gradle task \'assembleStagingDebug\'... Done                 35.1s\n\xe2\x9c\x93  Built build/app/outputs/flutter-apk/app-staging-debug.apk.\nInstalling build/app/outputs/flutter-apk/app.apk...                10.5s\nVMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:56037/_2tNx8J1Lj8=/\nVMServiceFlutterDriver: Isolate found with number: 4501853398952855\nVMServiceFlutterDriver: Isolate is paused at start.\nVMServiceFlutterDriver: Attempting to resume isolate\nD/EGL_emulation(29263): eglMakeCurrent: 0xa27a1bc0: ver 3 0 (tinfo 0xa2a835b0)\nI/flutter (29263): 00:00 +0: (setUpAll)\nVMServiceFlutterDriver: Connected to Flutter application.\nI/flutter (29263): 00:00 +1: My Tests Basic Home Screen Smoke test\nI/flutter (29263): (The following exception is now available via WidgetTester.takeException:)\nI/flutter (29263): \xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (29263): The following assertion was thrown running a test:\nI/flutter (29263): \'package:flutter/src/foundation/binding.dart\': Failed assertion: line 55 pos 12:\nI/flutter (29263): \'!_debugInitialized\': is not true.\nI/flutter (29263): \nI/flutter (29263): Either the assertion indicates an error in the framework itself, or we should provide substantially\nI/flutter (29263): more information in this error message to help you determine and fix the underlying cause.\nI/flutter (29263): In either case, please report this assertion by filing a bug on GitHub:\nI/flutter (29263):   https://github.com/flutter/flutter/issues/new?template=2_bug.md\nI/flutter (29263): \nI/flutter (29263): When the exception was thrown, this was the stack:\nI/flutter (29263): #2      new BindingBase (package:flutter/src/foundation/binding.dart:55:12)\nI/flutter (29263): #3      new _WidgetsFlutterBinding&BindingBase&GestureBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #4      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #5      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #6      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #7      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #8      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #9      new\n_WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #10     new WidgetsFlutterBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #11     new CustomImageCache (package:app/custom_image_cache.dart)\nI/flutter (29263): #12     main (package:app/main_staging.dart:51:3)\nI/flutter (29263): #13     main.<anonymous closure>.<anonymous closure> (file:///Users/Documents/my_app/integration_test/app_test.dart:29:7)\nI/flutter (29263): #14     main.<anonymous closure>.<anonymous closure> (file:///Users/Documents/my_app/integration_test/app_test.dart:28:49)\nI/flutter (29263): #15     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): (elided 3 frames from class _AssertionError and package:stack_trace)\nI/flutter (29263): \nI/flutter (29263): The test description was:\nI/flutter (29263):   Basic Home Screen Smoke test\nI/flutter (29263): \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (29263): (If WidgetTester.takeException is called, the above exception will be ignored. If it is not, then the above exception will be dumped when another\nexception is caught by the framework or when the test ends, whichever happens first, and then the test will fail due to having not caught or expected the\nexception.)\nI/flutter (29263): \xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (29263): The following assertion was thrown running a test:\nI/flutter (29263): \'package:flutter/src/foundation/binding.dart\': Failed assertion: line 55 pos 12:\nI/flutter (29263): \'!_debugInitialized\': is not true.\nI/flutter (29263): \nI/flutter (29263): Either the assertion indicates an error in the framework itself, or we should provide substantially\nI/flutter (29263): more information in this error message to help you determine and fix the underlying cause.\nI/flutter (29263): In either case, please report this assertion by filing a bug on GitHub:\nI/flutter (29263):   https://github.com/flutter/flutter/issues/new?template=2_bug.md\nI/flutter (29263): \nI/flutter (29263): When the exception was thrown, this was the stack:\nI/flutter (29263): #2      new BindingBase (package:flutter/src/foundation/binding.dart:55:12)\nI/flutter (29263): #3      new _WidgetsFlutterBinding&BindingBase&GestureBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #4      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #5      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #6      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #7      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #8      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #9      new\n_WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #10     new WidgetsFlutterBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #11     new CustomImageCache (package:app/custom_image_cache.dart)\nI/flutter (29263): #12     main (package:app/main_staging.dart:51:3)\nI/flutter (29263): #13     main.<anonymous closure>.<anonymous closure> (file:///Users/cs/Documents/my_app/integration_test/app_test.dart:29:7)\nI/flutter (29263): #14     main.<anonymous closure>.<anonymous closure> (file:///Users/cs/Documents/my_app/integration_test/app_test.dart:28:49)\nI/flutter (29263): #15     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): (elided 3 frames from class _AssertionError and package:stack_trace)\nI/flutter (29263): \n\nThe test description was:\n  Basic Home Screen Smoke test\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\n\nend of failure 1\n\n\n\nI/flutter (29881):   \'package:flutter_test/src/binding.dart\': Failed assertion: line 1648 pos 12: \'!_expectingFrame\': is not true.\n\n\n
Run Code Online (Sandbox Code Playgroud)\n

我有以下文件设置

\n

测试驱动程序/integration_driver.dart

\n
Running "flutter pub get" in my_app...              2,651ms\nRunning Gradle task \'assembleStagingDebug\'...                           \nRunning Gradle task \'assembleStagingDebug\'... Done                 35.1s\n\xe2\x9c\x93  Built build/app/outputs/flutter-apk/app-staging-debug.apk.\nInstalling build/app/outputs/flutter-apk/app.apk...                10.5s\nVMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:56037/_2tNx8J1Lj8=/\nVMServiceFlutterDriver: Isolate found with number: 4501853398952855\nVMServiceFlutterDriver: Isolate is paused at start.\nVMServiceFlutterDriver: Attempting to resume isolate\nD/EGL_emulation(29263): eglMakeCurrent: 0xa27a1bc0: ver 3 0 (tinfo 0xa2a835b0)\nI/flutter (29263): 00:00 +0: (setUpAll)\nVMServiceFlutterDriver: Connected to Flutter application.\nI/flutter (29263): 00:00 +1: My Tests Basic Home Screen Smoke test\nI/flutter (29263): (The following exception is now available via WidgetTester.takeException:)\nI/flutter (29263): \xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (29263): The following assertion was thrown running a test:\nI/flutter (29263): \'package:flutter/src/foundation/binding.dart\': Failed assertion: line 55 pos 12:\nI/flutter (29263): \'!_debugInitialized\': is not true.\nI/flutter (29263): \nI/flutter (29263): Either the assertion indicates an error in the framework itself, or we should provide substantially\nI/flutter (29263): more information in this error message to help you determine and fix the underlying cause.\nI/flutter (29263): In either case, please report this assertion by filing a bug on GitHub:\nI/flutter (29263):   https://github.com/flutter/flutter/issues/new?template=2_bug.md\nI/flutter (29263): \nI/flutter (29263): When the exception was thrown, this was the stack:\nI/flutter (29263): #2      new BindingBase (package:flutter/src/foundation/binding.dart:55:12)\nI/flutter (29263): #3      new _WidgetsFlutterBinding&BindingBase&GestureBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #4      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #5      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #6      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #7      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #8      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #9      new\n_WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #10     new WidgetsFlutterBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #11     new CustomImageCache (package:app/custom_image_cache.dart)\nI/flutter (29263): #12     main (package:app/main_staging.dart:51:3)\nI/flutter (29263): #13     main.<anonymous closure>.<anonymous closure> (file:///Users/Documents/my_app/integration_test/app_test.dart:29:7)\nI/flutter (29263): #14     main.<anonymous closure>.<anonymous closure> (file:///Users/Documents/my_app/integration_test/app_test.dart:28:49)\nI/flutter (29263): #15     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): (elided 3 frames from class _AssertionError and package:stack_trace)\nI/flutter (29263): \nI/flutter (29263): The test description was:\nI/flutter (29263):   Basic Home Screen Smoke test\nI/flutter (29263): \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (29263): (If WidgetTester.takeException is called, the above exception will be ignored. If it is not, then the above exception will be dumped when another\nexception is caught by the framework or when the test ends, whichever happens first, and then the test will fail due to having not caught or expected the\nexception.)\nI/flutter (29263): \xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (29263): The following assertion was thrown running a test:\nI/flutter (29263): \'package:flutter/src/foundation/binding.dart\': Failed assertion: line 55 pos 12:\nI/flutter (29263): \'!_debugInitialized\': is not true.\nI/flutter (29263): \nI/flutter (29263): Either the assertion indicates an error in the framework itself, or we should provide substantially\nI/flutter (29263): more information in this error message to help you determine and fix the underlying cause.\nI/flutter (29263): In either case, please report this assertion by filing a bug on GitHub:\nI/flutter (29263):   https://github.com/flutter/flutter/issues/new?template=2_bug.md\nI/flutter (29263): \nI/flutter (29263): When the exception was thrown, this was the stack:\nI/flutter (29263): #2      new BindingBase (package:flutter/src/foundation/binding.dart:55:12)\nI/flutter (29263): #3      new _WidgetsFlutterBinding&BindingBase&GestureBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #4      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #5      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #6      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #7      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #8      new _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #9      new\n_WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding\n(package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #10     new WidgetsFlutterBinding (package:flutter/src/widgets/binding.dart)\nI/flutter (29263): #11     new CustomImageCache (package:app/custom_image_cache.dart)\nI/flutter (29263): #12     main (package:app/main_staging.dart:51:3)\nI/flutter (29263): #13     main.<anonymous closure>.<anonymous closure> (file:///Users/cs/Documents/my_app/integration_test/app_test.dart:29:7)\nI/flutter (29263): #14     main.<anonymous closure>.<anonymous closure> (file:///Users/cs/Documents/my_app/integration_test/app_test.dart:28:49)\nI/flutter (29263): #15     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:156:29)\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): <asynchronous suspension>\nI/flutter (29263): (elided 3 frames from class _AssertionError and package:stack_trace)\nI/flutter (29263): \n\nThe test description was:\n  Basic Home Screen Smoke test\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\n\nend of failure 1\n\n\n\nI/flutter (29881):   \'package:flutter_test/src/binding.dart\': Failed assertion: line 1648 pos 12: \'!_expectingFrame\': is not true.\n\n\n
Run Code Online (Sandbox Code Playgroud)\n

集成测试/app_test.dart

\n
import \'package:integration_test/integration_test_driver.dart\';\n\nFuture<void> main() => integrationDriver();\n\n
Run Code Online (Sandbox Code Playgroud)\n

我正在运行的命令

\n
flutter drive \\\n  --flavor dev \\\n  --driver=test_driver/integration_driver.dart \\\n  --target=integration_test/app_test.dart\n
Run Code Online (Sandbox Code Playgroud)\n

main 函数有这样的设置:

\n
import \'package:app/main_staging.dart\' as stagingApp;\nimport \'package:flutter_test/flutter_test.dart\';\nimport \'package:integration_test/integration_test.dart\';\n\nvoid main() {\n  IntegrationTestWidgetsFlutterBinding.ensureInitialized();\n\n  group("My tests", () {\n    testWidgets(\'Basic Home Screen Smoke test\', (WidgetTester tester) async {\n      stagingApp.main();\n      await tester.pumpWidget(stagingApp.MyApp());\n      // await Future.delayed(Duration(seconds: 1));\n      await tester.pumpAndSettle(Duration(seconds: 20));\n    });\n  });\n}\n
Run Code Online (Sandbox Code Playgroud)\n

inn*_*ich 2

在 test_driver/integration_driver.dart 添加IntegrationTestWidgetsFlutterBinding.ensureInitialized();

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

Future<void> main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  return integrationDriver();
}
Run Code Online (Sandbox Code Playgroud)