Potential Issues with ActivityScenario

295 views
Skip to first unread message

mark...@willowtreeapps.com

unread,
Dec 3, 2018, 1:23:18 PM12/3/18
to androidx-test-discuss

ActivityScenario.launch(IndexActivity.class);

1/5 times when using ActivityScenario to launch my activity, I am getting this error as described in this SO post.



10:54:42 V/InstrumentationResultParser: java.lang.AssertionError: Activity never becomes requested state "[RESUMED]" (last lifecycle transition = "STOPPED")
10:54:42 V/InstrumentationResultParser: at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:228)
10:54:42 V/InstrumentationResultParser: at androidx.test.core.app.ActivityScenario.moveToState(ActivityScenario.java:368)
10:54:42 V/InstrumentationResultParser: at com.myapplication.android.test.HomeTest.launchActivity(HomeTest.java:30)
10:54:42 V/InstrumentationResultParser: at java.lang.reflect.Method.invoke(Native Method)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
10:54:42 V/InstrumentationResultParser: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
10:54:42 V/InstrumentationResultParser: at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:76)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
10:54:42 V/InstrumentationResultParser: at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.Suite.runChild(Suite.java:128)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.Suite.runChild(Suite.java:27)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
10:54:42 V/InstrumentationResultParser: at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
10:54:42 V/InstrumentationResultParser: at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
10:54:42 V/InstrumentationResultParser: at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
10:54:42 V/InstrumentationResultParser: at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
10:54:42 V/InstrumentationResultParser: at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
10:54:42 V/InstrumentationResultParser: at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)

Has anyone else had flakiness in the state of their activities when using ActivityScenario?

Brett Chabot

unread,
Dec 4, 2018, 12:28:31 PM12/4/18
to mark...@willowtreeapps.com, androidx-t...@googlegroups.com
Thanks for the report. Would you mind filing an issue here https://github.com/android/android-test/issues ? 

--
You received this message because you are subscribed to the Google Groups "androidx-test-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidx-test-di...@googlegroups.com.
To post to this group, send email to androidx-t...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/androidx-test-discuss/825ae205-a6e7-472e-9e36-3d6c531a1e16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mark...@willowtreeapps.com

unread,
Dec 5, 2018, 1:22:03 PM12/5/18
to androidx-test-discuss
I have updated a bit more on the SO post: https://stackoverflow.com/questions/53598321/androidx-test-activityscenario-java-lang-assertionerror-activity-never-becomes/53638398#53638398

The TL;DR is that there is a big limitation of scenario.waitForActivityToBecomeAnyOf(State.RESUMED, State.DESTROYED);  within launch(Intent startActivityIntent) method of ActivityScenario.

It would be awesome if we could optionally specify what states we want to wait for before launching. I can file an issue on this as well. 

Thanks Brett.

-Mark Han
To unsubscribe from this group and stop receiving emails from it, send an email to androidx-test-discuss+unsub...@googlegroups.com.

mark...@willowtreeapps.com

unread,
Dec 7, 2018, 11:33:26 AM12/7/18
to androidx-test-discuss
Reply all
Reply to author
Forward
0 new messages