Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech QA/Testing 2 years ago
Posted on 16 Aug 2022, this text provides information on QA/Testing related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I'm trying to use the new FragmentScenario APIs of the androidx testing libraries for local testing and instrumentation testing(androidTest). The api works fine in local environment but in instrumental testing, it gives error: java.lang.AssertionError: Activity never becomes requested state "[RESUMED, DESTROYED]" (last lifecycle transition = "PRE_ON_CREATE")"
Help me in instumental testing(androidTest)
Please check complete error detail:
java.lang.AssertionError: Activity never becomes requested state "[RESUMED, DESTROYED]" (last lifecycle transition = "PRE_ON_CREATE") at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:228) at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:198) at androidx.fragment.app.testing.FragmentScenario.internalLaunch(FragmentScenario.java:169) at androidx.fragment.app.testing.FragmentScenario.launchInContainer(FragmentScenario.java:160) at com.techzis.avatr.LoginFragmentTest1.dummyTest(LoginFragmentTest1.kt:26) at java.lang.reflect.Method.invoke(Native Method) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
I believe there is a limitation within the launch(Intent startActivityIntent) method of ActivityScenario. It only wants the Activity to be RESUMED or DESTROYED and if it isn't within 4.5 seconds then it throws that error.
launch(Intent startActivityIntent)
Within public static ActivityScenario launch(Intent startActivityIntent) of Activity Scenario, check the logic scenario.waitForActivityToBecomeAnyOf(State.RESUMED, State.DESTROYED);
public static ActivityScenario launch(Intent startActivityIntent)
scenario.waitForActivityToBecomeAnyOf(State.RESUMED, State.DESTROYED);
If you can create your own custom Activity Scenario and adjust this line of code to be something like scenario.waitForActivityToBecomeAnyOf(State.ON_PRE_CREATE, State.DESTROYED); then it will theoretically work for you.
scenario.waitForActivityToBecomeAnyOf(State.ON_PRE_CREATE, State.DESTROYED);
This is happening because the Lifecycle.State of your Activity when launching the Fragment is not either of the two specific lifecycle states specified by ActivityScenario. Again, I believe this may be a limitation of the API and I am filing an issue under Android-Test Repo. https://github.com/android/android-test/issues/new
Lifecycle.State
https://github.com/android/android-test/issues/new
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.