I have an Activity which has two Views - which are shown depending on the network condition. 
  LinearLayout recyclerView = (LinearLayout) findViewById(R.id.recycler_view);
  LinearLayout errorParent = (LinearLayout) findViewById(R.id.error_parent);
  if(Utils.isNetworkAvailable()){
      recyclerView.setVisibility(View.VISIBLE);
      errorParent.setVisibility(View.GONE);
  }else{
      recyclerView.setVisibility(View.GONE);
      errorParent.setVisibility(View.VISIBLE);
}
I have written an Espresso test for testing Network conditions. Before running the test, I manually switch off the Internet.
ViewInteraction viewInteraction = onView(withId(R.id.recycler_view));
viewInteraction.check(matches(isDisplayed()));
Since there is no Internet, the recycler_view is GONE, and thus it is  not  present in the view hierarchy. But when running the code I am not getting NoMatchingViewException. Ideally when the view is not present in the hierarchy, I should get the above exception. Instead I am getting AssertionFailedError. 
What is the reason for this behavior?
 
     
     
    