title: Android Junit4 test on UI thread
body: <p>I'm writing unit tests for Android using Junit4 syntax, via android test support library(<a href="https://code.google.com/p/android-test-kit/wiki/AndroidJUnitRunnerUserGuide" rel="noreferrer">here</a>). I want to test my custom view. The test involves clicking on a checkbox and making sure that a value in another place gets properly updated, but I'm getting this error when I try to run the test:</p>
  
  <pre><code>android.util.AndroidRuntimeException: Animators may only be run on Looper threads
  at android.animation.ValueAnimator.start(ValueAnimator.java:1002)
  at android.animation.ValueAnimator.start(ValueAnimator.java:1050)
  at android.animation.ObjectAnimator.start(ObjectAnimator.java:829)
  at android.graphics.drawable.AnimatedStateListDrawable$AnimationDrawableTransition.start(AnimatedStateListDrawable.java:294)
  at android.graphics.drawable.AnimatedStateListDrawable.selectTransition(AnimatedStateListDrawable.java:226)
  at android.graphics.drawable.AnimatedStateListDrawable.onStateChange(AnimatedStateListDrawable.java:145)
  at android.graphics.drawable.Drawable.setState(Drawable.java:599)
  at android.widget.CompoundButton.drawableStateChanged(CompoundButton.java:438)
  at android.view.View.refreshDrawableState(View.java:16032)
  at android.widget.CompoundButton.setChecked(CompoundButton.java:143)
  at android.widget.CompoundButton.toggle(CompoundButton.java:113)
  </code></pre>
  
  <p>I'm not defining any custom animations and I don't really care about them for this test, but I assume it's Android 5.0 material theme that creates a checkbox animation.</p>
  
  <p>I'm assuming the exception is thrown because the test doesn't run on a UI thread and the animator can't animate. So how do I run the test on a UI thread?</p>