Guest User

Untitled

a guest
Jan 9th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. @RunWith(AndroidJUnit4.class)
  2. public class SignInActivityTest {
  3.  
  4. private static final String USERNAME = "Username";
  5. private static final String PASSWORD = "Password";
  6. private static final String TOO_SHORT_PASSWORD = "u";
  7. private static final String EXPECTED_ERROR_MESSAGE = "Oops something went wrong, is your username and password more than 4 characters?";
  8.  
  9. @Rule
  10. public ActivityTestRule mActivityRule = new ActivityTestRule<>(
  11. MainActivity.class);
  12.  
  13. @Test
  14. public void signIn_ValidCredentials_loginPossible() {
  15. onView(withId(R.id.main_activity_sign_in_button)).perform(click());
  16. onView(withId(R.id.sign_in_activity_username_field)).perform(typeText(USERNAME));
  17. onView(withId(R.id.sign_in_activity_password_field)).perform(typeText(PASSWORD));
  18. onView(withId(R.id.sign_in_activity_submit_button)).perform(click());
  19. onView(withId(R.id.main_activity_sign_in_button)).check(matches(isDisplayed()));
  20. Application.setSignedOut();
  21. }
  22.  
  23. @Test
  24. public void signIn_UsernameTooShort_loginNotPossible() throws InterruptedException {
  25. onView(withId(R.id.main_activity_sign_in_button)).perform(click());
  26. onView(withId(R.id.sign_in_activity_username_field)).perform(typeText(TOO_SHORT_PASSWORD));
  27. onView(withId(R.id.sign_in_activity_password_field)).perform(typeText(PASSWORD));
  28. onView(withId(R.id.sign_in_activity_submit_button)).perform(click());
  29. onView(withText(EXPECTED_ERROR_MESSAGE)).check(matches(isDisplayed()));
  30. }
  31. }
Add Comment
Please, Sign In to add comment