Reputation: 83
i'm trying to create an ui-test in my app but with no luck. every time i get the error:
android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
here is my test code:
@RunWith(AndroidJUnit4.class)
public class UITestApp {
@ClassRule
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
@Rule
public ActivityTestRule<SplashActivity> mainActivityTestRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void testMainActivity(){
onView(withId(R.id.imageView)).check(matches(isDisplayed()));
Screengrab.screenshot("screenshot");
}
}
i am running my test on emulator, and the gradle.build seems to be okay.
Upvotes: 0
Views: 1409
Reputation: 2024
The trace says it all - you need to getActivity. Try adding this to the code:
private SplashActivity splashActivity;
@Before
public void setActivity() {
splashActivity = mainActivityTestRule.getActivity();
}
Upvotes: 1