Skip to content

Instantly share code, notes, and snippets.

@creativepsyco
Created July 25, 2015 18:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativepsyco/bd7ce1a75b933941c68e to your computer and use it in GitHub Desktop.
Save creativepsyco/bd7ce1a75b933941c68e to your computer and use it in GitHub Desktop.
SimpleTest
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.isEnabled;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.not;
@LargeTest
public class BasicTest extends ActivityInstrumentationTestCase2<LoginActivity> {
public BasicTest() {
super(LoginActivity.class);
}
@Override
public void setUp() throws Exception {
super.setUp();
}
public void testWalkthroughFlow() throws InterruptedException {
/**
* This function tests the entire workflow for boarding.
* If this test passes then it means the flow was a success.
*/
onView(withId(R.id.txt_email))
.check(matches(isDisplayed()));
onView(withId(R.id.btn_sign_in))
.check(matches(not(isEnabled())));
onView(withId(R.id.txt_email))
.perform(typeText("*****"));
onView(withId(R.id.btn_sign_in))
.check(matches(isEnabled()));
onView(withId(R.id.btn_sign_in))
.perform(click());
onView(withId(R.id.txt_verify_code))
.check(matches(isDisplayed()));
onView(withId(R.id.btn_verify))
.check(matches(not(isEnabled())));
onView(withId(R.id.txt_verify_code))
.perform(typeText("*****"));
onView(withId(R.id.btn_verify))
.check(matches(isEnabled()));
onView(withId(R.id.btn_verify))
.perform(click());
onView(withId(R.id.btn_sub))
.check(matches(isDisplayed()));
onView(withId(R.id.btn_sub))
.perform(click());
onView(withText(R.string.ui_im_sure))
.check(matches(isDisplayed()));
onView(withText(R.string.ui_im_sure))
.perform(click());
onView(withText(R.string.ui_enable_notifications))
.check(matches(isDisplayed()));
onView(withText(R.string.ui_enable_notifications))
.perform(click());
onView(withText(R.string.welcome_ui))
.check(matches(isDisplayed()));
onView(withText(R.string.ui_done))
.check(matches(isDisplayed()));
/*onView(withText(R.string.ui_done))
.perform(click());*/
}
public void testIfEditTextShows() throws InterruptedException {
onView(withText("Sign in")).check(matches(isDisplayed()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment