Skip to content

Instantly share code, notes, and snippets.

@up1
Created June 11, 2016 15:10
Show Gist options
  • Select an option

  • Save up1/c6e60fcb85c9be3086b25a5bd2f17825 to your computer and use it in GitHub Desktop.

Select an option

Save up1/c6e60fcb85c9be3086b25a5bd2f17825 to your computer and use it in GitHub Desktop.
Espresso Test Record
LargeTest
@RunWith(AndroidJUnit4.class)
public class NotesActivityTest {
@Rule
public ActivityTestRule<NotesActivity> mActivityTestRule = new ActivityTestRule<>(NotesActivity.class);
@Test
public void notesActivityTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(com.example.android.testing.notes.R.id.fab_add_notes),
withParent(withId(com.example.android.testing.notes.R.id.coordinatorLayout)),
isDisplayed()));
floatingActionButton.perform(click());
ViewInteraction appCompatEditText = onView(
allOf(withId(com.example.android.testing.notes.R.id.add_note_title), isDisplayed()));
appCompatEditText.perform(replaceText("new title"));
ViewInteraction appCompatEditText2 = onView(
allOf(withId(com.example.android.testing.notes.R.id.add_note_description), isDisplayed()));
appCompatEditText2.perform(replaceText("ggggh"));
ViewInteraction floatingActionButton2 = onView(
allOf(withId(com.example.android.testing.notes.R.id.fab_add_notes),
withParent(withId(com.example.android.testing.notes.R.id.coordinatorLayout)),
isDisplayed()));
floatingActionButton2.perform(click());
ViewInteraction appCompatEditText3 = onView(
allOf(withId(com.example.android.testing.notes.R.id.add_note_description), withText("ggggh"), isDisplayed()));
appCompatEditText3.perform(replaceText("gggghhh"));
ViewInteraction textView = onView(
allOf(withId(com.example.android.testing.notes.R.id.note_detail_title), withText("new title"), isDisplayed()));
textView.check(matches(withText("new title")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment