Skip to content

Instantly share code, notes, and snippets.

@luizmarcus
Created February 23, 2016 02:04
Show Gist options
  • Save luizmarcus/d8df0ea88d416e102360 to your computer and use it in GitHub Desktop.
Save luizmarcus/d8df0ea88d416e102360 to your computer and use it in GitHub Desktop.
@RunWith(AndroidJUnit4.class)
@LargeTest
public class LoginTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
@Test
public void executarTesteLoginContaCorreta() {
//Insere o usuário no campo user
onView(withId(R.id.user)).perform(typeText("Testeapp"), closeSoftKeyboard());
//Insere a senha no campo pass
onView(withId(R.id.pass)).perform(typeText("Password"), closeSoftKeyboard());
//Clica no botao submit
onView(withId(R.id.submit)).perform(click());
//Verifica se o texto é exibido no textView da SecondActivity
onView(withId(R.id.success)).check(matches(withText("Logado!")));
}
@Test
public void executarTesteLoginContaErrada() {
//Insere o usuário no campo user
onView(withId(R.id.user)).perform(typeText("Usuario"), closeSoftKeyboard());
//Insere a senha no campo pass
onView(withId(R.id.pass)).perform(typeText("Senha"), closeSoftKeyboard());
//Clica no botao submit
onView(withId(R.id.submit)).perform(click());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment