Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck on executing tests of apk with entrypoint test_bundle.dart #1794

Closed
shrijanRegmi opened this issue Oct 11, 2023 · 19 comments
Closed

Stuck on executing tests of apk with entrypoint test_bundle.dart #1794

shrijanRegmi opened this issue Oct 11, 2023 · 19 comments

Comments

@shrijanRegmi
Copy link

shrijanRegmi commented Oct 11, 2023

Steps to reproduce

  1. Do the setup mentioned in the docs for Android
  2. Run the command : patrol test --flavor dev -t integration_test/app_test.dart

Actual results

  1. Shows : Completed building apk with entrypoint test_bundle.dart
  2. But stuck on : Executing tests of apk with entrypoint test_bundle.dart

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.
      
No device specified, using the first one (192.168.1.68:5555)
• Building apk with entrypoint test_bundle.dart...
✓ Completed building apk with entrypoint test_bundle.dart (14.5s)
• Executing tests of apk with entrypoint test_bundle.dart on device 192.168.1.68:5555...

logs_with_verbose.txt

Patrol version

patro: ^2.3.0

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.0
Program adb found in /Users/shrijanregmi/Library/Android/sdk/platform-tools//adb
Env var $ANDROID_HOME set to /Users/shrijanregmi/Library/Android/sdk/
Program xcodebuild found in /usr/bin/xcodebuild
Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller

Flutter Doctor output

Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.13.0, on macOS 14.0 23A344 darwin-arm64, locale en-NP)
    ! Warning: `flutter` on your path resolves to /Users/shrijanregmi/Projects/Flutter/sdk/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/shrijanregmi/fvm/versions/3.13.0. Consider adding /Users/shrijanregmi/fvm/versions/3.13.0/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.19.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/shrijanregmi/fvm/versions/3.13.0. Consider adding /Users/shrijanregmi/fvm/versions/3.13.0/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.82.3)
[✓] Connected device (3 available)
[✓] Network resources
@balajiks-dev
Copy link

Same issue for me too.

This is my issue.
• Building apk with entrypoint test_bundle.dart...
✓ Completed building apk with entrypoint test_bundle.dart (3.9s)
• Executing tests of apk with entrypoint test_bundle.dart on emulator-5554...
See the report at: file:///Users/balajiks/Projects/Flutter/project_name/build/app/reports/androidTests/connected/flavors/elements/index.html
✗ Failed to execute tests of apk with entrypoint test_bundle.dart on emulator-5554 (Gradle test execution failed with code 1) (8.7s)
Exception: Gradle test execution 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.

@Guillergood
Copy link
Contributor

It happened to me also, the exact same thing. Running --verbose option it seems that it does not get any tests on the way:

: > Task :app:connectedDebugAndroidTest
: Starting 0 tests on Android(AVD) - 13
:
Instrumentation did not complete:
Instrumentation code: 0
Instrumentation result bundle:

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:connectedDebugAndroidTest'.

✗ Failed to execute tests of apk with entrypoint test_bundle.dart on emulator-5554 (Gradle test execution failed with code 1) (47.7s)

@bartekpacia
Copy link
Contributor

Hi, sorry for the problems.

Did it work on earlier versions and just broke on 2.3.0? If yes, you might be hitting #1725.

@Guillergood
Copy link
Contributor

In my case, I am new on patrol. I wanted to migrate some tests, but unable to do so. Followed the 'Getting started' in the docs. I changed the name test to 'test1', still having the same issue. Trying to debug it I found this error (executing it with debug with Intellij Idea, maybe it is not the way to do so).

ClientException with SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 39400, uri=http://localhost:8081/initialize

This exception is raised when the NativeAutomator is calling initialize().
@bartekpacia can you give me some steps to debug properly? Maybe I can pull more usable info about this 😄

@shrijanRegmi
Copy link
Author

Hey guys,

My issue is different than yours. I don't get any error message - nor the execution fails. It's just stuck on > Task :app:connectedDevDebugAndroidTest and does not proceed to anything.

@bartekpacia
Copy link
Contributor

executing it with debug with Intellij Idea, maybe it is not the way to do so).

You must use patrol_cli to run Patrol integration tests (the ones that have nativeAutomation: true set in patrolTest(). Unfortunately running from IDE directly, with debugging attached, is not supported right now. See #1777.

@bartekpacia
Copy link
Contributor

@shrijanRegmi Please create a new issue.

@shrijanRegmi
Copy link
Author

@shrijanRegmi Please create a new issue.

Why should I create a new issue? I have created the issue with the same exact problem that I am having, if you check the title, description, logs. Everyone else is talking about their own error in the replies.

@bartekpacia
Copy link
Contributor

Why should I create a new issue?

Ah sorry, I didn't notice you're the OP.

Anyway, all of you should attach output of adb logcat to your comments/issues, otherwise it's just guesswork.

@bartekpacia
Copy link
Contributor

Please try using latest patrol v2.3.1.

@Guillergood
Copy link
Contributor

After test with the lastest version of patrol and patrol_cli

10-13 16:33:37.842 12268 12268 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.example.app.test/pl.leancode.patrol.PatrolJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.PatrolJUnitRunner" on path: DexPathList
[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~0Yz2ga10iem80x3Y0KHqyg==/com.example.app.test-dP2SCiL-0sJs9esoT6Bsdw==/base.apk", zip file "/data/app/~~uWZcvtvqhdKkXBdGQn2onQ==/com.example.app-gjJPfFXTmY-pXTZ_-AMFTQ==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.app.ActivityThread.initInstrumentation(ActivityThread.java:6939)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6723)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2134)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7898)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.PatrolJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~0Yz2ga10iem80x3Y0KHqyg==/com.example.app.test-dP2SCiL-0sJs9esoT6Bsdw==/base.apk", zip file "/data/app/~~uWZcvtvqhdKkXBdGQn2onQ==/com.example.app-gjJPfFXTmY-pXTZ_-AMFTQ==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: at android.app.ActivityThread.initInstrumentation(ActivityThread.java:6935)
10-13 16:33:37.842 12268 12268 E AndroidRuntime: ... 10 more
10-13 16:33:37.856 12268 12268 I Process : Sending signal. PID: 12268 SIG: 9

@bartekpacia
Copy link
Contributor

That's weird. Do you have ProGuard enabled?

@Guillergood
Copy link
Contributor

Yes, when I get home I will try to keep your files for testing

@shrijanRegmi
Copy link
Author

patrol: ^2.4.0-dev.3 solved my issue and I was able to run everything normally on an emulator. However, it still does not work on my physical Android device.

@bartekpacia
Copy link
Contributor

@shrijanRegmi Did 2.3.1 also work for you?

@Guillergood
Copy link
Contributor

Guillergood commented Oct 14, 2023

In my case I have to set minify=false and only working with patrol: ^2.3.1. I created this #1804 to warn people of the proguard

@bartekpacia
Copy link
Contributor

Disabling ProGuard is not always an option, especially for release builds.

We should advise users to exclude Patrol's classes in their proguard-rules.pro.

@Guillergood
Copy link
Contributor

Sure, I have only advised it for debugging purposes (buildType = debug) . I couldn't make it work trying to keep the classes in proguard file.

@bartekpacia
Copy link
Contributor

If you think your issue is ProGuard-related, see #1804.

If ProGuard is disabled in your build and it still fails to execute, then it's most likely an error in your setup. Make sure to thoroughly go over Getting Started again.

I'm closing this since there's no minimal, reproducible sample was provided by the OP.

Feel free to open a new issue with all the required information provided.

@bartekpacia bartekpacia closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
@leancodepl leancodepl locked and limited conversation to collaborators Oct 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants