patrol
patrol copied to clipboard
Generated test_bundle.dart file having import issue
Steps to reproduce
I just make a demo as the document said
but having an issue with generated import don't know why
Actual results
generated file need to be error less
Logs
Logs
In next major release, patrolTest method will be intended for UI tests.
If you want to use Patrol in your widget tests, use patrol_finders package.
For more information, see https://patrol.leancode.co/patrol-finders-release
Disable this warning by setting the PATROL_FINDERS environment variable.
Verbose mode enabled. More logs will be printed.
Received 1 test target(s)
Received test target: D:\flutter_demo_projects\flutter_testcase\.\integration_test\login_view_patrol_test.dart
Generated entrypoint D:\flutter_demo_projects\flutter_testcase\integration_test\test_bundle.dart with 1 bundled test(s)
$ flutter --no-version-check devices --machine
No device specified, using the first one (RZCN800JJ9L)
Received 1 device(s) to run on
Received device: RZCN800JJ9L
Received 6 --dart-define(s) (0 custom, 6 internal)
Received internal --dart-define: PATROL_WAIT=0
Received internal --dart-define: PATROL_APP_PACKAGE_NAME=com.example.flutter_testcase
Received internal --dart-define: PATROL_ANDROID_APP_NAME=My App
Received internal --dart-define: PATROL_IOS_APP_NAME=My App
Received internal --dart-define: INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false
Received internal --dart-define: PATROL_TEST_LABEL_ENABLED=true
• Building apk with entrypoint test_bundle.dart...
$ .\gradlew.bat :app:assembleDebug -Ptarget=D:\flutter_demo_projects\flutter_testcase\integration_test\test_bundle.dart -Pdart-defines=UEFUUk9MX1dBSVQ9MA==,UEFUUk9MX0FQUF9QQUNLQUdFX05BTU
U9Y29tLmV4YW1wbGUuZmx1dHRlcl90ZXN0Y2FzZQ==,UEFUUk9MX0FORFJPSURfQVBQX05BTUU9TXkgQXBw,UEFUUk9MX0lPU19BUFBfTkFNRT1NeSBBcHA=,SU5URUdSQVRJT05fVEVTVF9TSE9VTERfUkVQT1JUX1JFU1VMVFNfVE9fTkFUSVZFPWZhbHNl,UEFUUk9MX1RFU1RfTEFCRUxfRU5BQkxFRD10cnVl
: > Task :app:preBuild UP-TO-DATE
: > Task :app:preDebugBuild UP-TO-DATE
: > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
:
: > Task :app:compileFlutterBuildDebug FAILED
Invalid depfile: D:\flutter_demo_projects\flutter_testcase\.dart_tool\flutter_build\788a6a6ba831791a8bc838a36f885749\kernel_snapshot.d
Invalid depfile: D:\flutter_demo_projects\flutter_testcase\.dart_tool\flutter_build\788a6a6ba831791a8bc838a36f885749\kernel_snapshot.d
Unhandled exception:
FileSystemException(uri=d:/flutter_demo_projects/flutter_testcase/integration_test/login_view_patrol_test.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1 IncrementalCompiler._initializeExperimentalInvalidation (package:front_end/src/fasta/incremental_compiler.dart:1268:56)
#2 IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:325:17)
<asynchronous suspension>
#3 IncrementalCompiler.compile (package:vm/incremental_compiler.dart:75:50)
<asynchronous suspension>
#4 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:604:11)
<asynchronous suspension>
#5 starter (package:frontend_server/starter.dart:102:12)
<asynchronous suspension>
#6 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:13:14)
<asynchronous suspension>
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1297
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
: 1 actionable task: 1 executed
✗ Failed to build apk with entrypoint test_bundle.dart (Gradle build failed with code 1) (4.0s)
Exception: Gradle build failed with code 1
#0 AndroidTestBackend.build.<anonymous closure> (package:patrol_cli/src/android/android_test_backend.dart:67:9)
<asynchronous suspension>
#1 DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
<asynchronous suspension>
#2 AndroidTestBackend.build (package:patrol_cli/src/android/android_test_backend.dart:42:5)
<asynchronous suspension>
#3 TestCommand._build (package:patrol_cli/src/commands/test.dart:234:7)
<asynchronous suspension>
#4 TestCommand.run (package:patrol_cli/src/commands/test.dart:167:5)
<asynchronous suspension>
#5 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6 PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:321:18)
<asynchronous suspension>
#7 PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:265:18)
<asynchronous suspension>
#8 patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:77:20)
<asynchronous suspension>
#9 main (file:///C:/Users/Vishal%20Patel/AppData/Local/Pub/Cache/hosted/pub.dev/patrol_cli-2.2.1/bin/main.dart:6:20)
<asynchronous suspension>
See the logs above to learn what happened. Also consider running with --verbose. If the logs still aren't useful, then it's a bug - please report it.
Exception: Gradle build failed with code 1
#0 AndroidTestBackend.build.<anonymous closure> (package:patrol_cli/src/android/android_test_backend.dart:67:9)
<asynchronous suspension>
#1 DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
<asynchronous suspension>
#2 AndroidTestBackend.build (package:patrol_cli/src/android/android_test_backend.dart:42:5)
<asynchronous suspension>
#3 TestCommand._build (package:patrol_cli/src/commands/test.dart:234:7)
<asynchronous suspension>
#4 TestCommand.run (package:patrol_cli/src/commands/test.dart:167:5)
<asynchronous suspension>
#5 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6 PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:321:18)
<asynchronous suspension>
#7 PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:265:18)
<asynchronous suspension>
#8 patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:77:20)
<asynchronous suspension>
#9 main (file:///C:/Users/Vishal%20Patel/AppData/Local/Pub/Cache/hosted/pub.dev/patrol_cli-2.2.1/bin/main.dart:6:20)
<asynchronous suspension>
Patrol version
patrol: ^2.3.1
Patrol Doctor output
Patrol Doctor output
In next major release, patrolTest method will be intended for UI tests.
If you want to use Patrol in your widget tests, use patrol_finders package.
For more information, see https://patrol.leancode.co/patrol-finders-release
Disable this warning by setting the PATROL_FINDERS environment variable.
Patrol CLI version: 2.2.1
Program adb found in C:\android\Sdk\platform-tools\adb.exe
Env var $ANDROID_HOME set to C:\android\Sdk
Flutter Doctor output
Flutter Doctor output
[√] Flutter (Channel stable, 3.13.7, on Microsoft Windows [Version 10.0.22621.2428], locale en-IN)
• Flutter version 3.13.7 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2f708eb839 (9 days ago), 2023-10-09 09:58:08 -0500
• Engine revision a794cf2681
• Dart version 3.1.3
• DevTools version 2.25.0
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at C:\android\Sdk
• Platform android-33-ext4, build-tools 33.0.1
• ANDROID_HOME = C:\android\Sdk
• Java binary at: E:\new android studio\Android Studio1\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Edge (web) • edge • web-javascript • Microsoft Edge 117.0.2045.60
[√] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories.
Hi, sorry for the problems.
This looks related to #1428. Might be caused by #1797.
What command did you use? Please post the exact invocation.
I am having the same problem when running patrol test --target ./integration_test/views/test.dart --flavor flavor_name
.
Error:
Target kernel_snapshot failed: ExceptionFAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\dalen\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1201
* What went wrong:
Execution failed for task ':app:compileFlutterBuildCoresensing_v2_androidDebug'.
> Process 'command 'C:\Users\dalen\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 41s
✗ Failed to build apk with entrypoint test_bundle.dart (Gradle build failed with code 1) (42.2s) Exception: Gradle build failed with code 1 See the logs above to learn what happened. Also consider running with --verbose. If the logs still aren't useful, then it's a bug - please report it. Exception: Gradle build failed with code 1 #0 AndroidTestBackend.build. (package:patrol_cli/src/android/android_test_backend.dart:67:9)
#1 DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
#2 AndroidTestBackend.build (package:patrol_cli/src/android/android_test_backend.dart:42:5)
#3 TestCommand._build (package:patrol_cli/src/commands/test.dart:234:7)
#4 TestCommand.run (package:patrol_cli/src/commands/test.dart:167:5)
#5 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
#6 PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:321:18)
#7 PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:265:18)
#8 patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:77:20)
#9 main (file:///C:/Users/dalen/AppData/Local/Pub/Cache/hosted/pub.dev/patrol_cli-2.2.1/bin/main.dart:6:20)
Patrol version: 2.3.1
Patrol Doctor:
Patrol CLI version: 2.2.1 Program adb found in C:\Users\dalen\AppData\Local\Android\Sdk\platform-tools\adb.exe Env var $ANDROID_HOME set to C:\Users\dalen\AppData\Local\Android\SdkFlutter doctor:
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22621.2428], locale de-DE) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [X] Visual Studio - develop for Windows X Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2022.2) [√] Connected device (4 available) [√] Network resources
Oi @C-8, how are you doing? Try to modify the begin of your target path to:
patrol test --target integration_test\views\test.dart --flavor flavor_name
Also try to run the flutter clean
command, today I've faced a problem related to build task from gradle, that only was solved by cleaning the project, I don't know why 😅
Oi @C-8, how are you doing? Try to modify the begin of your target path to:
patrol test --target integration_test\views\test.dart --flavor flavor_name
Also try to run the
flutter clean
command, today I've faced a problem related to build task from gradle, that only was solved by cleaning the project, I don't know why 😅
This worked!
My Test Code Example:
void main() {
patrolTest(
'counter state is the same after going to home and switching apps',
($) async {
await $.pumpWidgetAndSettle(
MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('app')),
backgroundColor: Colors.blue,
),
),
);
// expect($('app'), findsOneWidget);
await $.native.disableWifi();
await Future.delayed(const Duration(seconds: 2));
await $.native.enableWifi();
await Future.delayed(const Duration(seconds: 2));
},
nativeAutomation: true,
config: PatrolTesterConfig(),
nativeAutomatorConfig:
NativeAutomatorConfig(packageName: "com.example.app"),
);
}
Unfortunately i can't run any native test code
Exception has occurred. _AssertionError ('package:flutter/src/foundation/binding.dart': Failed assertion: line 153 pos 12: '_debugInitializedType == null': Binding is already initialized to IntegrationTestWidgetsFlutterBinding)
Please help me
I started to experience the same problem after migration from Flutter 3.19 to Flutter 3.22.
The patrol version does not matter. Might it be related? When I build app normally (flutter run), everything is fine. Problem happens when build app using patrol test --target integration_test/home_screen_test.dart --flavor qa --dart-define=integration_test=true
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Aflutter_gen%2Fgen_l10n%2Fapp_localizations.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34)
#1 asFileUri (package:vm/kernel_front_end.dart:752)
#2 writeDepfile (package:vm/kernel_front_end.dart:892)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:680)
<asynchronous suspension>
#4 starter (package:frontend_server/starter.dart:101)
<asynchronous suspension>
#5 main (file:///Volumes/Work/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:13)
<asynchronous suspension>
Target kernel_snapshot failed: Exception
Logs
^^^^^^^^^^^^^^^^
lib/app_notifications/model/notification_dialogs/missing_google_api_service_dialog.dart:8:14: Error: The getter 'AppLocalizations' isn't defined for the class 'MissingGoogleApiServiceDialog'.
- 'MissingGoogleApiServiceDialog' is from 'package:app/app_notifications/model/notification_dialogs/missing_google_api_service_dialog.dart' ('lib/app_notifications/model/notification_dialogs/missing_google_api_service_dialog.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'AppLocalizations'.
title: AppLocalizations.of(context).missing_service_dialog_title,
^^^^^^^^^^^^^^^^
lib/app_notifications/model/notification_dialogs/missing_google_api_service_dialog.dart:9:16: Error: The getter 'AppLocalizations' isn't defined for the class 'MissingGoogleApiServiceDialog'.
- 'MissingGoogleApiServiceDialog' is from 'package:app/app_notifications/model/notification_dialogs/missing_google_api_service_dialog.dart' ('lib/app_notifications/model/notification_dialogs/missing_google_api_service_dialog.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'AppLocalizations'.
content: AppLocalizations.of(context).missing_service_dialog_content,
^^^^^^^^^^^^^^^^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Aflutter_gen%2Fgen_l10n%2Fphrase_localizations.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34)
#1 asFileUri (package:vm/kernel_front_end.dart:752)
#2 writeDepfile (package:vm/kernel_front_end.dart:892)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:680)
<asynchronous suspension>
#4 starter (package:frontend_server/starter.dart:101)
<asynchronous suspension>
#5 main (file:///Volumes/Work/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:13)
<asynchronous suspension>
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script '/opt/homebrew/Caskroom/flutter/3.10.5/flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy' line: 1629
* What went wrong:
Execution failed for task ':app:compileFlutterBuildQaDebug'.
> Process 'command '/opt/homebrew/Caskroom/flutter/3.10.5/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
✗ Failed to build apk with entrypoint test_bundle.dart (Gradle build failed with code 1) (20.1s)
Exception: Gradle build failed with code 1
See the logs above to learn what happened. Also consider running with --verbose. If the logs still aren't useful, then it's a bug - please report it.
Exception: Gradle build failed with code 1
#0 AndroidTestBackend.build.
Flutter version
Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 5dcb86f68f (13 days ago) • 2024-05-09 07:39:20 -0500 Engine • revision f6344b75dc Tools • Dart 3.4.0 • DevTools 2.34.3Patrol doctor
Patrol CLI version: 2.7.0 Flutter command: flutter Flutter 3.22.0 • channel stable Android: • Program adb found in /opt/homebrew/bin/adb • Program xcodebuild found in /usr/bin/xcodebuild • Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller
@Wreos I don't think the issue you described is related to this one. Yours seems to be caused by this regression in the latest Flutter version
#2251