Skip to content

[Screenshots] ZenDesk crash in JPScreenshotTest #17130

Open
@AliSoftware

Description

@AliSoftware

Parent: #17128

On some occasions, I get a crash on ZenDesk initialization when testing JPScreenshotTest.

Note: So far I've seen this happen when running the test in it or zh-CN, but not in en-US or fr-FR. But I haven't tested extensively or re-ran many iterations of this, so I'm not sure if I was just lucky in those last two locales or if it was just random and a coincidence and the crash might not be related to the locale at all.

Steps to reproduce

Run the JPScreenshotTest in Android studio multiple times, or use bundle exec fastlane screenshots app:jetpack locale:zh-CN in the Terminal, until the app crashes on the below stacktrace, indicating ZenDesk setup wasn't done properly.

Stacktrace

bundle exec fastlane screenshots app:jetpack locale:zh-CN

[10:02:36]: Running tests for locale: zh-CN
[10:02:36]: $ /Users/olivierhalligon/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument --no-window-animation -w \
-e testLocale zh-CN \
--no-hidden-api-checks \
-e appendTimestamp false \
-e class org.wordpress.android.ui.screenshots.JPScreenshotTest \
com.jetpack.android.test/org.wordpress.android.WordPressTestRunner
[10:02:41]: ▸ org.wordpress.android.ui.screenshots.JPScreenshotTest:
[10:02:41]: ▸ Process crashed while executing jPScreenshotTest(org.wordpress.android.ui.screenshots.JPScreenshotTest):
[10:02:41]: ▸ java.lang.IllegalArgumentException: Zendesk needs to be setup before this method can be called
[10:02:41]: ▸ 	at org.wordpress.android.support.ZendeskHelper.enablePushNotifications(ZendeskHelper.kt:197)
[10:02:41]: ▸ 	at org.wordpress.android.push.GCMRegistrationIntentService.sendRegistrationToken(GCMRegistrationIntentService.java:86)
[10:02:41]: ▸ 	at org.wordpress.android.push.GCMRegistrationIntentService.lambda$onHandleWork$0$org-wordpress-android-push-GCMRegistrationIntentService(GCMRegistrationIntentService.java:53)
[10:02:41]: ▸ 	at org.wordpress.android.push.GCMRegistrationIntentService$$ExternalSyntheticLambda0.onComplete(Unknown Source:2)
[10:02:41]: ▸ 	at com.google.android.gms.tasks.zzi.run(com.google.android.gms:play-services-tasks@@18.0.1:1)
[10:02:41]: ▸ 	at android.os.Handler.handleCallback(Handler.java:873)
[10:02:41]: ▸ 	at android.os.Handler.dispatchMessage(Handler.java:99)
[10:02:41]: ▸ 	at android.os.Looper.loop(Looper.java:193)
[10:02:41]: ▸ 	at android.app.ActivityThread.main(ActivityThread.java:6669)
[10:02:41]: ▸ 	at java.lang.reflect.Method.invoke(Native Method)
[10:02:41]: ▸ 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[10:02:41]: ▸ 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[10:02:41]: ▸ INSTRUMENTATION_RESULT: shortMsg=Process crashed.
[10:02:41]: ▸ INSTRUMENTATION_CODE: 0

Note: If you need to run the test in a locale other than en-US, I'd be curious if you manage to do that from AndroidStudio. I personally haven't managed to pass the -e testLocale zh-CN value to the test runner from Android Studio despite setting it in the "Instrumentation arguments" window (see: p1661527010684449-slack-C02QANACA), so the only workaround I found was to put breakpoints in the constructors of both LocaleTestRule.class and WPLocaleTestRule.java, and change the value of the variable after it has (failed to) read it from the call to LocaleUtil.getTestLocale(). 🤷

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions