-
Notifications
You must be signed in to change notification settings - Fork 314
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
Got AssertionError while launching a activity by ActivityScenario.launch #1199
Comments
me too |
1 similar comment
me too |
@sayasheng @wangprofessor @biezhihua , could you provide a sample to reproduce this problem? It will help to validate and fix this problem. |
https://github.com/biezhihua/ActivityScenarioTestDemo I provide a demo project, you can reproduce this problem. |
java.lang.AssertionError: Activity never becomes requested state "[DESTROYED, CREATED, RESUMED, STARTED]" (last lifecycle transition = "PRE_ON_CREATE") |
@utzcoz Have you made any progress? |
Sorry for that. Looks like Brett and other maintainers are busy recently. I will take look at this issue this week before they have time for it. And I will post updates to here. |
I can't run your sample at Android Studio. Could you provide one sample with basic Android Studio structure, and without alibaba's gitlab link that I can't access? |
Okay, I reproduce this problem with my local sample app. It will raise when add |
Looks like androidx.test core uses |
Found a sample to test multiprocess: https://github.com/android/android-test/tree/9d25d24ec7abe5021672c0423a992e87b44eb261/testapps/multiprocess_testapp. Maybe you can check it whether it can help you. |
It looks like related to Robolectric tests. Hi @brettchabot , does |
Found another tutorial to test app with multi-process with espresso remote: https://developer.android.com/training/testing/espresso/multiprocess. |
From testing result, we can start an Activity in default process with |
Thank your work! It will raise when not add |
You can try it again. |
I updated the sample project : https://github.com/biezhihua/ActivityScenarioTestDemo, you can reproduce the problem without process tag. You will get same information. |
@biezhihua I will check your new sample this weekend. |
You didn't add your test Activity to your AndroidManifest.xml, so system can't find your test Activity, and raised this error to you. |
Sorry, this is my error, i forget to add Activity to my AndroidManifest.xml. I updated the sample project : https://github.com/biezhihua/ActivityScenarioTestDemo, you can reproduce the problem. |
@biezhihua There are some things about your sample:
|
Thank you very much. |
Sorry for delayed response. ActivityScenario won't support testing an Activity running in a different process than the Instrumentation. At the very least I feel ActivityScenario should detect and report a better error message in this situation. Does it help if you specify <instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.example.activityscenariotestdemo"
android:targetProcesses=":welcome"
/> in your test's AndroidManifest.xml? |
This comment has been minimized.
This comment has been minimized.
oops thanks |
I ran into this today for a Jetpack Compose project. I am able to work around this issue by removing |
Description
Got Error messages as below:
java.lang.AssertionError: Activity never becomes requested state "[CREATED, DESTROYED, RESUMED, STARTED]" (last lifecycle transition = "PRE_ON_CREATE") at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)
some message shows in log
E/TestRunner( 3422): ----- begin exception -----
E/TestRunner( 3422): java.lang.AssertionError: Activity never becomes requested state "[RESUMED, CREATED, DESTROYED, STARTED]" (last lifecycle transition = "PRE_ON_CREATE")
E/TestRunner( 3422): at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)
E/TestRunner( 3422): at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:272)
E/TestRunner( 3422): at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:226)
Steps to Reproduce
AndroidX Test and Android OS Versions
OS version: android 10
androidx.test.espresso core: 3.4.0
androidx.test.rule: 1.4.0
workaround solution
don't give android:process name to the test activity
The text was updated successfully, but these errors were encountered: