title: Android RecyclerView Adapter Item count is returning 0 on unit testing
body: <p>I am trying to test RecyclerView with AndroidJunit4, it is my test code:</p>
  
  <pre><code>@Rule
      public ActivityTestRule&lt;ProductListActivity&gt; rule  = new  ActivityTestRule&lt;&gt;(ProductListActivity.class);
  
  ............................
  ..........................
  
  @Test
      public void ensureDataIsLoadingOnSuccess() throws Exception {
          ProductListActivity activity = rule.getActivity();
          ...........................
          ............
  
          activity.runOnUiThread(new Runnable() {
          public void run() {
              activity.displayProducts(asList(product1, product2), 0);
          }
      });
  
          assertEquals(2, mAdapter.getItemCount());
          assertThat(((ProductAdapter) mAdapter).getItemAtPosition(0),sameInstance(product1));
          assertThat(((ProductAdapter) mAdapter).getItemAtPosition(1),sameInstance(product2));
  
  
      }
  </code></pre>
  
  <p>Here is my code for displayProducts() in Activity:</p>
  
  <pre><code>@Override
      public void displayProducts(List&lt;Product&gt; products, Integer pageNo) {
          progressBar.setVisibility(View.GONE);
          if (pageNo == 0 &amp;&amp; products.size() == 0) {
              noProductTextView.setVisibility(View.VISIBLE);
          } else {
              mProductAdapter.addProduct(products);
              noProductTextView.setVisibility(View.GONE);
              productListView.setVisibility(View.VISIBLE);
          }
      }
  </code></pre>
  
  <p>It is giving error like: </p>
  
  <pre><code>junit.framework.AssertionFailedError: expected:&lt;2&gt; but was:&lt;0&gt;
  at junit.framework.Assert.fail(Assert.java:50)
  at junit.framework.Assert.failNotEquals(Assert.java:287)
  at junit.framework.Assert.assertEquals(Assert.java:67)
  at junit.framework.Assert.assertEquals(Assert.java:199)
  at junit.framework.Assert.assertEquals(Assert.java:205)
  at com.kaushik.myredmart.ui.ProductListActivityTest.ensureDataIsLoadingOnSuccess(ProductListActivityTest.java:94)
  </code></pre>
  
  <p>Please help what is the problem in my code?</p>