title: Using MockWebServer with Robolectric
body: <p>I'm trying to unit test some API calls using MockWebServer and Robolectric. </p>
  
  <p>My test class is annotated with:</p>
  
  <pre><code>@RunWith(RobolectricGradleTestRunner.class)
  @Config(constants = BuildConfig.class, sdk = 23)
  </code></pre>
  
  <p>However when trying to build the Retrofit instance I get the following exception:</p>
  
  <pre><code>java.lang.NullPointerException
      at android.os.Handler.__constructor__(Handler.java:229)
      at android.os.Handler.&lt;init&gt;(Handler.java)
      at retrofit2.Platform$Android$MainThreadExecutor.&lt;init&gt;(Platform.java:105)
      at retrofit2.Platform$Android.defaultCallbackExecutor(Platform.java:97)
      at retrofit2.Retrofit$Builder.build(Retrofit.java:556)
  </code></pre>
  
  <p>The code I'm using to build the retrofit instance:</p>
  
  <pre><code>Retrofit retrofit = new Retrofit.Builder()
                  .baseUrl(mMockServer.url(""))
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
  </code></pre>
  
  <p>The exception above is returned upon calling <code>.build()</code>.</p>
  
  <p>How do I fix this problem?</p>