Skip to content

Commit

Permalink
Issue #330 - Added the espresso test for invalid age error toast (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArunSelvam11 authored and emartynov committed Feb 6, 2018
1 parent b161f87 commit 75bee88
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
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.RootMatchers.withDecorView;
import static android.support.test.espresso.matcher.ViewMatchers.isChecked;
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.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withSpinnerText;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -189,4 +191,20 @@ public void check_009_IfICanSubmitAnyData() {
onView(withId(R.id.activity_hello_button_start))
.perform(scrollTo(), click());
}

@Test
public void check_010_IfIEnterWrongAge() {
// Entering invalid age
onView(withId(R.id.activity_hello_age))
.perform(typeText("0"), closeSoftKeyboard());

// Click on GET STARTED button
onView(withId(R.id.activity_hello_button_start))
.perform(scrollTo(), click());

// Checking the toast is displayed with invalid message
onView(withText(R.string.helloactivity_age_invalid))
.inRoot(withDecorView(not(mRule.getActivity().getWindow().getDecorView())))
.check(matches(isDisplayed()));
}
}

0 comments on commit 75bee88

Please sign in to comment.