Skip to content

Instantly share code, notes, and snippets.

@heitorcolangelo
Last active July 25, 2016 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heitorcolangelo/09ef7620ade3b943420d093a61dbb803 to your computer and use it in GitHub Desktop.
Save heitorcolangelo/09ef7620ade3b943420d093a61dbb803 to your computer and use it in GitHub Desktop.
LoginActivityTest - empty state test - refactor 2
@Test
public void whenPasswordIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
testEmptyFieldState(R.id.login_username);
}
@Test
public void whenUserNameIsEmpty_andClickOnLoginButton_shouldDisplayDialog() {
testEmptyFieldState(R.id.login_password);
}
private void testEmptyFieldState(int notEmptyFieldId){
onView(withId(notEmptyFieldId)).perform(typeText("defaultText"));
onView(withId(R.id.login_button)).perform(click());
onView(withText(R.string.validation_message)).check(matches(isDisplayed()));
onView(withText(R.string.ok)).perform(click());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment