title: Android Espresso how to write cases for Fragments and its child's from Activity?
body: <p>I am working on writing the test cases for my application and it worked well for Activities. But when it comes to Fragment inside the ViewPager my cases are failed. </p>
  
  <p>Below test case fails because the fragment shows an empty view if run this directly. </p>
  
  <pre><code>public class SentimentsFragmentEspressoTest {
  
      @Rule
      public FragmentTestRule&lt;SentimentsFragment&gt; mFragmentTestRule = new FragmentTestRule&lt;&gt;(SentimentsFragment.class);
  
      @Test
      public void fragment_can_be_instantiated() {
  
          // Launch the activity to make the fragment visible
          mFragmentTestRule.launchActivity(null);
  
          // Then use Espresso to test the Fragment
  
          onView(withId(R.id.listSentiments))
                  .perform(RecyclerViewActions.scrollToPosition(4));
      }
  }
  </code></pre>
  
  <p>How do I overcome this issue?</p>