Skip to content
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ dependencies {
// or "androidTestCompile", depending on the app's implementation
// androidTestCompile for now, might change later
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:3.0.0'

}


11 changes: 8 additions & 3 deletions app/src/androidTest/assets/user.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
name=Boris
email=borisqa@bayqa.com
password=bayqa12345

name=Oxana
email=oxanaga@bayqa.com
password=bayqa2017
bankName=Bank of America
accountNumber=123456789
passwordForAccount=bankqapassword

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Properties;

/**
* Created by borisgurtovyy on 9/7/17.

*/

public class BaseTest {
Expand All @@ -26,8 +26,9 @@ public void setProperties(Properties properties) {
@Before
public void baseSetUp() throws IOException {
properties = new Properties();
AssetManager testAssetManager = InstrumentationRegistry.getContext().getAssets();
AssetManager.AssetInputStream assetStream = (AssetManager.AssetInputStream) testAssetManager.open("user.properties");

AssetManager testAssetManger = InstrumentationRegistry.getContext().getAssets();
AssetManager.AssetInputStream assetStream = (AssetManager.AssetInputStream) testAssetManger.open("user.properties");
properties.load(assetStream);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package io.mattcarroll.androidtesting.login;

import android.support.test.rule.ActivityTestRule;

import org.junit.Before;
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;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by max on 9/4/2017.
*/

public class EspressoSignInTest extends BaseTest{

@Rule
public final ActivityTestRule<SplashActivity> activityRule =
new ActivityTestRule<>(SplashActivity.class, false,true);

@Test
public void userSignInPersonalInfoRequiredFieldsAreRequired(){

onView(withId(R.id.edittext_email))
.perform(typeText("BayQA@yahoo.com"));
onView(withId(R.id.edittext_password))
.perform(typeText("password"));
onView(withId(R.id.button_sign_in))
.perform(scrollTo())
.perform(click());
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("password"));

//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 logInAndAddBankAccount(){


//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("passwordForAccount"));

// click link button
clickButton(R.id.button_link_account);

}


}
Loading