The Activity can be manually launched with launchActivity(Intent), and manually finished with finishActivity() During the duration of the test you will be able to manipulate your Activity directly using the reference obtained from getActivity(). If the Activity is finished and relaunched, the reference returned by getActivity() will always point to the current instance of the Activity.
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
//getActivity()