Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith(AndroidJUnit4.class)
- public class SignInActivityTest {
- private static final String USERNAME = "Username";
- private static final String PASSWORD = "Password";
- private static final String TOO_SHORT_PASSWORD = "u";
- private static final String EXPECTED_ERROR_MESSAGE = "Oops something went wrong, is your username and password more than 4 characters?";
- @Rule
- public ActivityTestRule mActivityRule = new ActivityTestRule<>(
- MainActivity.class);
- @Test
- public void signIn_ValidCredentials_loginPossible() {
- onView(withId(R.id.main_activity_sign_in_button)).perform(click());
- onView(withId(R.id.sign_in_activity_username_field)).perform(typeText(USERNAME));
- onView(withId(R.id.sign_in_activity_password_field)).perform(typeText(PASSWORD));
- onView(withId(R.id.sign_in_activity_submit_button)).perform(click());
- onView(withId(R.id.main_activity_sign_in_button)).check(matches(isDisplayed()));
- Application.setSignedOut();
- }
- @Test
- public void signIn_UsernameTooShort_loginNotPossible() throws InterruptedException {
- onView(withId(R.id.main_activity_sign_in_button)).perform(click());
- onView(withId(R.id.sign_in_activity_username_field)).perform(typeText(TOO_SHORT_PASSWORD));
- onView(withId(R.id.sign_in_activity_password_field)).perform(typeText(PASSWORD));
- onView(withId(R.id.sign_in_activity_submit_button)).perform(click());
- onView(withText(EXPECTED_ERROR_MESSAGE)).check(matches(isDisplayed()));
- }
- }
Add Comment
Please, Sign In to add comment