Given this block of code:
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
_view.displaySomething();
}
});
I want to call Mockito's verify(_view).displaySomething()
in my unit test, but I receive the following error:
java.lang.RuntimeException: Method getMainLooper in android.os.Looper not mocked.
Can someone point me to what I could do to achieve this without error?
That is common problem with testing Android-related classes, they don't have default implementations when running pure JUnit test.
You have two possibilities: