title: Testing method that uses Realm
body: <p>I have a Database data source that is using Realm. So now I want to test that class but I'm facing some problems about how to use fixtures and how to mock Realm.
  My database data source looks like:</p>
  
  <pre><code>public class DatabaseDataSource {
      private Realm realm;
  
      public DatabaseDataSource(Realm realm) {
          this.realm = realm;
      }
  
  
      public Observable&lt;RealmResults&gt; getContacts(String firstName, String lastName, String city, String zipCode) {
  
          final RealmQuery realmQuery = realm.where(Contact.class);
          if(!TextUtils.isEmpty(firstName)) {
              realmQuery.contains("firstName", firstName);
          }
          if(!TextUtils.isEmpty(lastName)) {
              realmQuery.contains("lastName", lastName));
          }
          if(!TextUtils.isEmpty(city)) {
              realmQuery.contains("city", city);
          }
          if(!TextUtils.isEmpty(zipCode)) {
              realmQuery.contains("zipCode", zipCode);
          }
  
          return realmQuery.findAll()
                      .asObservable();
      }
  }
  </code></pre>
  
  <p>I'm using Robolectrics for other tests, and, in this case, I want to have a list of contacts in my mocked realm so I can check that filtering is working fine. How can I do that? 
  I've tried doing:</p>
  
  <pre><code>@RunWith(RobolectricTestRunner.class)
  @Config(manifest=Config.NONE)
  public class DatabaseDataSourceTest extends BaseTest {
  
  
      private DatabaseDataSource databaseDataSource;
  
      Realm realm;
  
      @Before
      public void setup() throws Exception {
  
          Realm.init(RuntimeEnvironment.application.getApplicationContext());
          Realm.setDefaultConfiguration(new RealmConfiguration.Builder().build());
          realm = Realm.getDefaultInstance();
  
          databaseDataSource = new DatabaseDataSource(realm);
      }
  
      @Test
      public void getContacts_filterByName() {
      databaseDataSource.getContacts("testName", null, null, null);
          // I don't know what to do here
      }
  
  }
  </code></pre>
  
  <p>But I'm getting the following exception when doing: </p>
  
  <pre><code>Realm.init(RuntimeEnvironment.application.getApplicationContext());
  
  java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/kc/76n8494x5cd2mtx340f27xch0000gn/T/android-tmp-robolectric409019390257818503/app_lib/librealm-jni.dylib
  </code></pre>
  
  <p>How should I do that?</p>