Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ android {
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

testBuildType 'espresso'
Expand Down
8 changes: 5 additions & 3 deletions app/src/androidTest/assets/user.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name=Boris
email=borisqa@bayqa.com
password=bayqa12345
name=Vitaly
email=a@test.com
password=qwerty1
accountNumber=1234567890
bankName=Chase
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.mattcarroll.androidtesting;


import android.content.res.AssetManager;
import android.support.test.InstrumentationRegistry;

Expand All @@ -8,9 +9,6 @@
import java.io.IOException;
import java.util.Properties;

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

public class BaseTest {
private Properties properties;
Expand All @@ -30,5 +28,4 @@ public void baseSetUp() throws IOException {
AssetManager.AssetInputStream assetStream = (AssetManager.AssetInputStream) testAssetManager.open("user.properties");
properties.load(assetStream);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package io.mattcarroll.androidtesting.login;


import android.support.test.espresso.matcher.ViewMatchers;
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.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<SplashActivity> activityRule =
new ActivityTestRule<>(SplashActivity.class, false, true);

@Test
public void userSignInVerifyNoLinkedAccounts() {
signIn();
onView(withId(R.id.textview_no_accounts))
.check(matches(isDisplayed()));
}

@Test
public void linkBankAccount() {
signIn();
//user click + sign
clickAddButton();
//user click Link Account
linkButtonClik();
//user types in Bank name, Account Number, and Password
linkNewBankAccount();
//user clicks Link
linkButtonClik();
}

private void clickAddButton() {
onView(withId(R.id.fab_manage_accounts))
.perform(click());
}

private void linkButtonClik() {
onView(withId(R.id.button_link_account))
.perform(click());
}

private void linkNewBankAccount() {
onView(withId(R.id.edittext_bank_name))
.perform(typeText(getProperties().getProperty("bankName")));
onView(withId(R.id.edittext_account_number))
.perform(typeText(getProperties().getProperty("accountNumber")));
onView(withId(R.id.edittext_password))
.perform(typeText(getProperties().getProperty("password")));
}

private void signIn() {
onView(ViewMatchers.withId(R.id.edittext_email))
.perform(typeText(getProperties().getProperty("email")));
onView(withId(R.id.edittext_password))
.perform(typeText(getProperties().getProperty("password")));
onView(withId(R.id.button_sign_in))
.perform(click());
}
}
Loading