title: Correct way to use IdlingResource in Espresso Android
body: <p>I'm writing UI tests with Espresso. App cooperates tightly with server, so in many cases, I need to wait for either value to be calculated, or data is got and displayed, etc. Espresso suggests using IdlingResource for this. 
  My IdlingResource classes look like this (simple and clear example).</p>
  
  <pre><code>public class IRViewVisible implements IdlingResource {
  
  private View view;
  private ResourceCallback callback;
  
  public IRViewVisible(View view) {
      this.view = view;
  }
  
  @Override
  public String getName() {
      return IRViewVisible.class.getName();
  }
  
  @Override
  public boolean isIdleNow() {
      if(view.getVisibility() == View.VISIBLE &amp;&amp; callback != null) {
          callback.onTransitionToIdle();
          return true;
      }
      return false;
  }
  
  @Override
  public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
      this.callback = resourceCallback;
  }
  }
  </code></pre>
  
  <p>Please correct me if I'm wrong anywhere (as sometimes it seems to me that my IdlingResources do not work properly).
  I register the idling resource in <code>setUp()</code> like this:</p>
  
  <pre><code>IRViewVisible ir = new IRViewVisible(View v);
  Espresso.registerIdlingResources(ir).
  </code></pre>
  
  <p>Unregister it on tearDown().</p>
  
  <p>I found <a href="http://dev.jimdo.com/2014/05/09/wait-for-it-a-deep-dive-into-espresso-s-idling-resources/">this article</a> (there is a section called "Register a component tied to an Activity instance") — I do not use his schema, but I checked hashcode of view that was set to IdlingResource after registering (in each method), and it's not the same view — all hashes are different. </p>
  
  <p>Another question: One Test class (it's results) can't have any effect on another Test class, can it? </p>