wordpress-mobile / wordpress-mobile/WordPress-Android
[Screenshots] ZenDesk crash in `JPScreenshotTest`
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 3.2k
- Forks
- 1.4k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 69
Description
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
itorzh-CN, but not inen-USorfr-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-CNvalue 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 bothLocaleTestRule.classandWPLocaleTestRule.java, and change the value of the variable after it has (failed to) read it from the call toLocaleUtil.getTestLocale(). 🤷
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with JPScreenshotTest and the stack trace path through ZendeskHelper.kt:197 and GCMRegistrationIntentService.java:86. Read how ZenDesk initialization and push-token handling are triggered during screenshot tests, then reproduce with the listed fastlane command and locales. Done means repeated JPScreenshotTest runs no longer crash with the setup exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- mobile, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100