title: Testing ActiveAndroid with Robolectric
body: <p>What can I do to get some test coverage on ActiveAndroid's ContentProvider in Robolectric? This simple test fails.</p>
  
  <p>The model:</p>
  
  <pre><code>@Table(name = "Things")
      public class Thing extends Model {
      public Thing() {
          super();
      }
  }
  </code></pre>
  
  <p>The test:</p>
  
  <pre><code>@RunWith(RobolectricTestRunner.class)
  public class ContentProviderTest {
  
    @Test
    public void itShouldQuery() throws Exception {
      new Thing().save();
      ContentResolver cr = new MainActivity().getContentResolver();
      assertNotNull(
          cr.query(Uri.parse("content://org.example/things"), 
                     null, null, null, null));
    }
  }
  </code></pre>
  
  <p>The resulting stack trace:</p>
  
  <pre><code>java.lang.NullPointerException: null
      at com.activeandroid.Cache.getTableInfo(Unknown Source)
      at com.activeandroid.Model.&lt;init&gt;(Unknown Source)
      at org.example.Thing.&lt;init&gt;(Thing.java:9)
      at org.example.ProviderTest.itShouldQuery(ProviderTest.java:25)
  </code></pre>
  
  <p>The application context should be ok. By default, Robolectric creates the application that appears in the manifest, which in this case is com.activeandroid.Application.</p>
  
  <p>So, I'm puzzled why the tableInfo in Cache is not initialized. Normal application execution works fine.</p>