How I learned to automate Android apps with Android Espresso

cloud based Espresso testing

Setting up Android Espresso

Writing the first Android Espresso test

Espresso.onView(Matchers.allOf(ViewMatchers.withText("enter text") , ViewMatchers.isDisplayed()));
onView(withId(R.id.home).perform(click())
@RunWith(AndroidJUnit4.class)
public class SampleTest {

/**
* Use {@link ActivityScenarioRule} to create and launch the activity under test.
*/
@Rule
public ActivityScenarioRule<MainActivity> activityScenarioRule =
new ActivityScenarioRule<MainActivity>(MainActivity.class);


@Test
public void ensureInputWorks() {
onView(withId(R.id.input1)).perform(click()).perform(typeText("this is a test"));

// Check that the text was changed.
onView(withId(R.id.input1)).check(matches(withText("this is a test")));
}
}

Running Android Espresso tests in the Cloud

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store