Unit testing and synced realms



I have a local realm and have been relying heavily on unit testing of local in-memory realms to maintain quality of my app. Now I am converting my Realm Cloud and I have found that it is impossible to use classes containing permissions in my unit tests. These objects are just not compatible with local realms. I understand that permissions only make sense for synced realms. However, I do want to keep my unit tests, and wish to be able to do this without having to run them connected to an object server.

Is there a way to create a configuration that allows for opening objects including permissions in java? I get errors when I try to add Permission objects to the local module. If not, what is the recommended way to unit test my app? I tried looking through the documentation but didn’t find anything that could help me out.


Check this link, may be helpful. The answer is about c#, but I guess in Java will be similar.


@Radek No, it doesn’t work in Java. Adding the permission class to the local module yields an exception :confused:


No comments from the Realm guys? Any tips on what I can do to unit test synced realms? Do I really need to run the tests against a server just because an object has a permission object?


If anyone is wondering, all you need to do to be able to local tests on objects that contains permissions is to add the ObjectPermissionsModule() to the local configuration. Big thanks to @mgeerling for helping me figuring this out!