Issue
In Android Studio, in the androidTest folder, I have this test case:
@RunWith(AndroidJUnit4.class)
@LargeTest
public class LoginActivityTest {
@Rule
public ActivityTestRule<LoginActivity> activityTestRule =
new ActivityTestRule<>(LoginActivity.class);
@Test
public void teamsListIsSortedAlphabetically() {
onView(withId(R.id.etEmail)).perform(click(), replaceText("[email protected]")
);
onView(withId(R.id.etPassword)).perform(click(), replaceText("asdasd")
);
onView(withId(R.id.bLoginSubmit)).perform(click());
}
}
The app launches LoginActivity, logs in, the next activity is shown for 1-2 seconds and then it exits the activity leaving me on the launcher screen. How do I make Espresso stay on that screen?
Solution
Sorry, but it's impossible.
Please read this Google reference: Automating User Interface Tests
Espresso, Robotium, Calabash and other UI test frameworks were made for short interaction testing events. It simulates an user's specific behavior - run app, do some tricks and (if successful) than close an app.
Of course, Espresso allow you to create custom idling resources and than register it in app.
The simplest way to hibernate a test for a specific amount of time is use method Thread.sleep(time_in_miliseconds)
, but like I said it's against idea of automated testing.
Answered By - piotrek1543
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.