the following is one of my Espresso test cases.
public void testLoginAttempt() {
Espresso.onView(ViewMatchers.withId(R.id.username)).perform(View
You may do it as follows:
@Test
public void testLoginAttempt() {
Espresso.onView(ViewMatchers.withId(R.id.username)).perform(ViewActions.clearText()).perform(ViewActions.typeText("nonexistinguser@example.com"));
Espresso.onView(ViewMatchers.withId(R.id.username)).perform(ViewActions.clearText()).perform(ViewActions.typeText("invalidpassword"));
Intents.init();
Espresso.onView(ViewMatchers.withId(R.id.login_button)).perform(ViewActions.click());
Intents.release();
}
java.lang.NullPointerException
is thrown if Intents.init()
is not called.