Updated #1: more info added to the end of this post
I\'m new to Android development and testing.
I have three Espresso tests. First test passes, but the
This seems to work for me to close all of the activities in the stack except the first one.
@After
@Override
public void tearDown() throws Exception
{
Intent intent = new Intent(getActivity(), getActivity().getClass());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Removes other Activities from stack
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
myActivity.startActivity(intent);
super.tearDown();
}