title: How to test a specific Activity with Espresso?
body: <p>I have only just started with testing in Android and this seems very basic but after much googling I still can't find the answer anywhere. </p>
  
  <p>In my Android app the first activity which is displayed is a login screen, followed by a home screen with options to navigate to other activities. In order to test the activity I want I currently have to move through these two activities first.</p>
  
  <p>How do I setup the Espresso test (using ActvityTestRule/JUnit4) so that it launches the activity I want to test straight away?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>More specifically, my issue is that in all tutorials I have seen for Espresso tests all tests start off at the main activity of the application with an ActivityTestRule that looks like this</p>
  
  <pre><code>@Rule
  public final ActivityTestRule&lt;MainActivity&gt; mRule = new ActivityTestRule&lt;MainActivity&gt;(MainActivity.class);
  </code></pre>
  
  <p>I want the tests to start at a specified activity, which currently I am having navigate to by constantly repeating test code like this</p>
  
  <pre><code>onView(withId(R.id.go_to_other_activity_button)).perform(click())
  </code></pre>