3

As long as I saw in a YouTube video that an android device tends to launch and show activities that are launched in my test, I think there is a problem here, since mine doesn't react at all (the screen is always on though, animations are turned off). When I was trying to test the activity which runs first in the app (logically), I tried to open the app by myself while testing and somehow it worked. Now I'm testing another one and this trick doesn't work anymore.

Anyways I always get the error: java.lang.AssertionError: Activity never becomes requested state "[RESUMED, STARTED, CREATED, DESTROYED]"

My test code uncludes:

val scenario = ActivityScenario.launch(HomeActivity::class.java)

And then I just check the presence of a layout element (textview or anything)

Any ideas why it may occur? Thanks in advance

UPD: android emulator works fine.

1 Answers1

5

this also happening to my test when following codelab from google kotlin unit test

when im trying to run the test via emulator, it run perfectly, but when i run into my device, which is xiaomi redmi note 5, the error showed up like yours,

i found an answer in this question and it directed to this github enter image description here enter image description here

i try to enable app permission "Display pop-up windows while running in the background", and when i run the test again, it passes

enter image description here

justnoone
  • 111
  • 2
  • 5