From 3416b0efa6ec896a460ff5393c4b392decf93789 Mon Sep 17 00:00:00 2001 From: okyska Date: Mon, 16 Oct 2017 18:07:32 -0700 Subject: [PATCH 1/4] fill information into user.properties --- app/src/androidTest/assets/user.properties | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/assets/user.properties b/app/src/androidTest/assets/user.properties index f87b97d..fbccf1d 100644 --- a/app/src/androidTest/assets/user.properties +++ b/app/src/androidTest/assets/user.properties @@ -1,3 +1,6 @@ -name=Boris -email=borisqa@bayqa.com -password=bayqa12345 \ No newline at end of file +name = Oxana +email = bayga@bayqa.com +passwordForLogin = bayqa12345 +bankName = bank +accountNumber = 789657865 +passwordForBankccount = bayqapasswordg \ No newline at end of file From 311519445d62db90a609995ec411f7f906c7312f Mon Sep 17 00:00:00 2001 From: okyska Date: Mon, 16 Oct 2017 22:44:08 -0700 Subject: [PATCH 2/4] added EspressoSignInTest class and changed test userSignInPersonalInfoRequiredFieldsAreRequired --- .../login/EspressoSignInTest.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java diff --git a/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java b/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java new file mode 100644 index 0000000..54aef2f --- /dev/null +++ b/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java @@ -0,0 +1,42 @@ +package io.mattcarroll.androidtesting.login; + + +import android.support.test.rule.ActivityTestRule; + +import org.junit.Rule; +import org.junit.Test; + +import io.mattcarroll.androidtesting.BaseTest; +import io.mattcarroll.androidtesting.R; +import io.mattcarroll.androidtesting.SplashActivity; + +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.action.ViewActions.scrollTo; +import static android.support.test.espresso.action.ViewActions.typeText; +import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; +import static android.support.test.espresso.matcher.ViewMatchers.withId; + +public class EspressoSignInTest extends BaseTest{ + + @Rule + public final ActivityTestRule activityRule= + new ActivityTestRule<>(SplashActivity.class, false, true); + + @Test + public void userSignInPersonalInfoRequiredFieldsAreRequired(){ + + onView(withId(R.id.edittext_email)) + .perform(typeText("email")); + onView(withId(R.id.edittext_password)) + .perform(typeText("password")); + onView(withId(R.id.button_sign_in)) + .perform( + scrollTo(), + click() + ); + onView(withId(R.id.textview_no_accounts)) + .check(matches(isDisplayed())); + } +} From 5c584ffd054e4d17a1efffc59528f8aa307035f0 Mon Sep 17 00:00:00 2001 From: okyska Date: Mon, 16 Oct 2017 23:26:10 -0700 Subject: [PATCH 3/4] added test logInAndBankAccount --- app/src/androidTest/assets/user.properties | 2 +- .../login/EspressoSignInTest.java | 63 ++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/assets/user.properties b/app/src/androidTest/assets/user.properties index fbccf1d..f7a9986 100644 --- a/app/src/androidTest/assets/user.properties +++ b/app/src/androidTest/assets/user.properties @@ -3,4 +3,4 @@ email = bayga@bayqa.com passwordForLogin = bayqa12345 bankName = bank accountNumber = 789657865 -passwordForBankccount = bayqapasswordg \ No newline at end of file +passwordForBankAccount = bayqapasswordg diff --git a/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java b/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java index 54aef2f..94ae21e 100644 --- a/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java +++ b/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java @@ -3,6 +3,7 @@ import android.support.test.rule.ActivityTestRule; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -17,6 +18,7 @@ import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; public class EspressoSignInTest extends BaseTest{ @@ -30,7 +32,7 @@ public void userSignInPersonalInfoRequiredFieldsAreRequired(){ onView(withId(R.id.edittext_email)) .perform(typeText("email")); onView(withId(R.id.edittext_password)) - .perform(typeText("password")); + .perform(typeText("passwordForLogin")); onView(withId(R.id.button_sign_in)) .perform( scrollTo(), @@ -39,4 +41,63 @@ public void userSignInPersonalInfoRequiredFieldsAreRequired(){ onView(withId(R.id.textview_no_accounts)) .check(matches(isDisplayed())); } + + //homework lesson 4 + + private static void fillFields(int fieldId, String textToType){ + onView(withId(fieldId)).perform( + typeText(textToType) + ); + } + + private static void scrollToButton(int fieldId){ + onView(withId(fieldId)).perform(scrollTo()); + + } + + private static void clickButton(int fieldId){ + onView(withId(fieldId)).perform(click()); + } + + private static void checkTextIsDisplayed(String textToCheck){ + onView(withText(textToCheck)).check(matches(isDisplayed())); + } + + @Before + public void SignIn(){ + //fill email + fillFields(R.id.edittext_email, getProperties().getProperty("email")); + + //fill password + fillFields(R.id.edittext_password, getProperties().getProperty("passwordForLogin")); + + //scroll to sign in button + scrollToButton(R.id.button_sign_in); + + //click on sign in button + clickButton(R.id.button_sign_in); + } + + @Test + public void logInAndBankAccount(){ + + //click on + button + clickButton(R.id.fab_manage_accounts); + + //click on link button + clickButton(R.id.button_link_account); + + //fill bank name + fillFields(R.id.edittext_bank_name, getProperties().getProperty("bankName")); + + //fill bank account number + fillFields(R.id.edittext_account_number, getProperties().getProperty("accountNumber")); + + //fill password for account + fillFields(R.id.edittext_password, getProperties().getProperty("passwordForBankAccount")); + + //click link button + clickButton(R.id.button_link_account); + + } } From 894ad56b8b0b9844b86d9f118a3232cbefb8d87a Mon Sep 17 00:00:00 2001 From: okyska Date: Thu, 19 Oct 2017 09:23:59 -0700 Subject: [PATCH 4/4] repaired test userSignInPersonalInfoRequiredFieldsAreRequired --- .../login/EspressoSignInTest.java | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java b/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java index 94ae21e..d2162dd 100644 --- a/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java +++ b/app/src/androidTest/java/io/mattcarroll/androidtesting/login/EspressoSignInTest.java @@ -1,6 +1,8 @@ package io.mattcarroll.androidtesting.login; +import android.content.res.Resources; +import android.support.test.InstrumentationRegistry; import android.support.test.rule.ActivityTestRule; import org.junit.Before; @@ -16,8 +18,10 @@ import static android.support.test.espresso.action.ViewActions.scrollTo; import static android.support.test.espresso.action.ViewActions.typeText; import static android.support.test.espresso.assertion.ViewAssertions.matches; +import static android.support.test.espresso.matcher.ViewMatchers.hasErrorText; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withResourceName; import static android.support.test.espresso.matcher.ViewMatchers.withText; public class EspressoSignInTest extends BaseTest{ @@ -25,24 +29,14 @@ public class EspressoSignInTest extends BaseTest{ @Rule public final ActivityTestRule activityRule= new ActivityTestRule<>(SplashActivity.class, false, true); + private Resources resources; - @Test - public void userSignInPersonalInfoRequiredFieldsAreRequired(){ - - onView(withId(R.id.edittext_email)) - .perform(typeText("email")); - onView(withId(R.id.edittext_password)) - .perform(typeText("passwordForLogin")); - onView(withId(R.id.button_sign_in)) - .perform( - scrollTo(), - click() - ); - onView(withId(R.id.textview_no_accounts)) - .check(matches(isDisplayed())); - } - - //homework lesson 4 + @Before + public void setup() { + // getTargetContext() operates on the application under test + // getContext() operates on the test APK context + resources = InstrumentationRegistry.getTargetContext().getResources(); + } private static void fillFields(int fieldId, String textToType){ onView(withId(fieldId)).perform( @@ -50,6 +44,11 @@ private static void fillFields(int fieldId, String textToType){ ); } + private void checkFieldHasError(int fieldId, int errorID){ + onView(withId(fieldId)) + .check(matches(hasErrorText(resources.getString(errorID)))); + } + private static void scrollToButton(int fieldId){ onView(withId(fieldId)).perform(scrollTo()); @@ -59,11 +58,8 @@ private static void clickButton(int fieldId){ onView(withId(fieldId)).perform(click()); } - private static void checkTextIsDisplayed(String textToCheck){ - onView(withText(textToCheck)).check(matches(isDisplayed())); - } - @Before + //@Before public void SignIn(){ //fill email fillFields(R.id.edittext_email, getProperties().getProperty("email")); @@ -81,6 +77,7 @@ public void SignIn(){ @Test public void logInAndBankAccount(){ + SignIn(); //click on + button clickButton(R.id.fab_manage_accounts); @@ -99,5 +96,14 @@ public void logInAndBankAccount(){ //click link button clickButton(R.id.button_link_account); + } + @Test + public void userSignInPersonalInfoRequiredFieldsAreRequired(){ + + scrollToButton(R.id.button_sign_in); + clickButton(R.id.button_sign_in); + checkFieldHasError(R.id.edittext_email, R.string.error_field_required); + + } }