-
Notifications
You must be signed in to change notification settings - Fork 319
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
ActivityScenario hangs on EmptyActivity after testing activity with launchMode=singleInstance #1115
Comments
Seems to be the same issue as in https://stackoverflow.com/questions/65112750/android-test-with-activityscenariorule-hanging-forever |
Also, some commenters on #676 seem to be running into this issue. Indeed, when changing the launchMode to singleTask as per #676 (comment), the test terminates immediately after execution. |
I'm hitting this issue too in a compose app. One of the app dependencies requires the activity have a launchMode of "singleInstance" though so changing to singleTask is no good for us. Has anyone found a solution to this? |
@brettchabot Do you have an idea what might be causing this? |
If it helps anyone, this is my workaround. It's definitely not a permanent solution, so if anyone has a better approach, feel free to share! Basically, I detect based on the gradle tasks to be executed if we're running the ui tests. Then with this information I set a placeholder that will be used in the def instrumentationTestTask = gradle.startParameter.taskNames.find { it == ":app:connectedDebugAndroidTest" }
if (instrumentationTestTask != null) {
println "Building instrumentation APK"
manifestPlaceholders += [activityLaunchMode: "singleTask"]
buildConfigField "boolean", "INSTRUMENTATION_MODE", "true"
} else {
manifestPlaceholders += [activityLaunchMode: "singleInstance"]
buildConfigField "boolean", "INSTRUMENTATION_MODE", "false"
} <activity
...
android:launchMode="${activityLaunchMode}"
... /> |
We tried both and it still hangs for a good 45 seconds, seems unrelated from what we can see, it is a lock in the |
Description
When testing an Activity that has
launchMode=singleInstance
with an ActivityScenarioRule, after the test is completed the text executor gets stuck in EmptyActivity for ~45 seconds before progressing to the next test.Steps to Reproduce
android:launchMode="singleInstance"
to the MainActivity's entry in AndroidManifest.xml@get:Rule val rule = ActivityScenarioRule(MainActivity::class.java)
to theExampleInstrumentedTest
ExampleInstrumentedTest
Expected Results
Test runs and quits immediately after
Actual Results
Test runs and gets stuck in EmptyActivity for about ~45 seconds
AndroidX Test and Android OS Versions
(physical) Pixel C, Android 8.1.0
(emulator) Pixel 2, API 30
The text was updated successfully, but these errors were encountered: