fernandohur fernandohur - 1 year ago 392
Android Question

Testing multiple activities with espresso

Is it possible to write tests across several activities using the android espresso framework?

Answer Source

Yes, it is possible. In one of the samples they have demoed this;

public void testTypingAndPressBack() {
// Close soft keyboard after type to avoid issues on devices with soft keyboard.
    .perform(typeText("Have a cup of Espresso."), closeSoftKeyboard());


// Clicking launches a new activity that shows the text entered above. You don't need to do
// anything special to handle the activity transitions. Espresso takes care of waiting for the
// new activity to be resumed and its view hierarchy to be laid out.
    .check(matches(withText(("Have a cup of Espresso."))));

// Going back to the previous activity - lets make sure our text was perserved.


Read the inline comment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download