Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. package qa.com.espressospoonstructure.tests;
  2.  
  3. import org.junit.Test;
  4.  
  5. import qa.com.espressospoonstructure.screenObjects.LoginScreen;
  6.  
  7. import static android.support.test.espresso.assertion.ViewAssertions.matches;
  8. import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
  9.  
  10. public class TestLoginScreen extends BaseTestCase<MainActivity> {
  11. /* Create the variable that will contain the instance of our Screen Object class*/
  12. private LoginScreen mLoginScreen;
  13.  
  14. /* Create our instance of Login Screen and any other screen object we might require.
  15. * Normally, you'll have to go thorugh several screens before running a test.*/
  16. public TestLoginScreen(){
  17. super(MainActivity.class);
  18. mLoginScreen = new LoginScreen();
  19. }
  20.  
  21. /* This example doesn't hold one, but it's normal to have a @Before method that navigates to the screen
  22. * before executing it. Being able to use that annotation is one of the advantages of using JUnit4*/
  23.  
  24. /* All tests have the @Test annotation.
  25. * Notice that the method name describes exactly the expected behavior for the specified action.
  26. * Also notice that the assertion is performed here and it does not rely on the Screen Object class.
  27. * */
  28. @Test
  29. public void shouldDisplayErrorWhenSubmittingInvalidPassword(){
  30. mLoginScreen.doLogin("ValidUsername", "InvalidPassword");
  31. LoginScreen.LOGIN_VALIDATION_INVALID_PASSWORD.check(matches(isDisplayed()));
  32. }
  33.  
  34. /* Notice that we reuse method 'doLogin'.
  35. * Difference lies on the test data we use and the assertion implemented.
  36. * */
  37. @Test
  38. public void shouldDisplayErrorWhenSubmittingInvalidUsernameFormat(){
  39. mLoginScreen.doLogin("InvalidUsername", "ValidPasswordFormat");
  40. mLoginScreen.LOGIN_VALIDATION_USERNAME_INVALID_FORMAT.check(matches(isDisplayed()));
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement