Skip to content
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

Tests works in the local but throws NoActivityResumedException in the action #191

Closed
ycagri opened this issue Sep 22, 2021 · 5 comments
Closed

Comments

@ycagri
Copy link

ycagri commented Sep 22, 2021

Some tests throw NoActivityResumedException. Longer description is here:
androidx.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?

This generally happens when the device is in lock mode. I use launchFragmentInContainer to test my fragments.

@ychescale9
Copy link
Member

Does it happen locally? This sometimes also happens due to flakiness of certain tests but without seeing your code it's hard to know.

@ycagri
Copy link
Author

ycagri commented Sep 22, 2021

It runs on the local. It is strange that only fails at one fragment test. Trying to figure out the reason. A bit more info in here:

07:46:58 V/InstrumentationResultParser: androidx.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
07:46:58 V/InstrumentationResultParser: at dalvik.system.VMStack.getThreadStackTrace(Native Method)
07:46:58 V/InstrumentationResultParser: at java.lang.Thread.getStackTrace(Thread.java:1720)
07:46:58 V/InstrumentationResultParser: at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:96)
07:46:58 V/InstrumentationResultParser: at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:59)
07:46:58 V/InstrumentationResultParser: at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:322)
07:46:58 V/InstrumentationResultParser: at androidx.test.espresso.ViewInteraction.check(ViewInteraction.java:306)
07:46:58 V/InstrumentationResultParser: at com.pitcher.android.instancelist.InstanceListFragmentTest.testRetrieveError(InstanceListFragmentTest.kt:131)

And the line 131 is:
onView(withText("Test Error!")).check(ViewAssertions.matches(withEffectiveVisibility(Visibility.VISIBLE)))

@ycagri
Copy link
Author

ycagri commented Sep 22, 2021

Hi again,

It is my bad. The problem was a permission request that shouldn't be asked there. Therefore, the test case stalls and throws this exception. However, it works locally due to permissions were already given. Sorry for the false flag.

@ycagri ycagri closed this as completed Sep 22, 2021
@LaxmikantMahamuni
Copy link

Hi @ycagri where permission should not be asked and what is correct place to ask it can you please elaborate.

Question:
When you got the error "androidx.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?"

That time permission were added locally and did you missed those permission on Github repository? which caused to test run locally but not at the Github CI.

@ycagri
Copy link
Author

ycagri commented Jul 9, 2024

This is a pretty old topic but the case was sth like this. There was a permission request which is asked on start up. In the local device, permissions were already given before running the tests. However, in the GitHub Actions a fresh device is created and the permission request screen was causing the issue. The activity shows the permission request dialog, since no action was taken test throws the androidx.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants