Running tests

14 views
Skip to first unread message

Nadav Weizmann

unread,
Oct 6, 2015, 11:04:16 AM10/6/15
to Realm Java
Hey,

Anyone has a good, solid example of testing models and relationships? (specifically many-to-many).

I find it hard to setup tests, especially without robolectric.

Thanks

Christian Melchior

unread,
Oct 6, 2015, 1:34:54 PM10/6/15
to Nadav Weizmann, realm...@googlegroups.com
Hi Nadav

What specifically do you want to test. This functionality is already covered by the unit tests by Realm itself, so you shouldn't need to write tests for it in your app. Also many-to-many references are first-class citizens in Realm, so they behave just like normal object references.

--
Christian Melchior
Senior Android Developer


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/3415f349-aefb-418e-afce-a722bb081021%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:128156143-1990#}

Nadav Weizmann

unread,
Oct 11, 2015, 7:04:23 AM10/11/15
to Realm Java
Hey Christian, 
Thanks for your quick reply.

I simply want to write my own unit-tests, i wanna have ORM models, with internal relationships between them and write tests for it (not to mention proprietary methods which uses them...).

For some reason, this was not as easy task as it usually is with other similar technologies...

Christian Melchior

unread,
Oct 12, 2015, 4:09:11 AM10/12/15
to Nadav Weizmann, realm...@googlegroups.com
Hi Nadav

Realm uses custom native code which isn't supported by Robolectric. We have an issue here tracking it: https://github.com/realm/realm-java/issues/904

Right now you have two options:
1) Treat Realm objects as normal objects, so just create them in memory if you want to test any business logic.
2) Run your tests as Instrumentation tests. This is e.g. what our own unit tests does at the moment: https://github.com/realm/realm-java/blob/master/realm/src/androidTest/java/io/realm/RealmObjectTest.java


--
Christian Melchior
Senior Android Developer


On Sun, Oct 11, 2015 at 11:04 AM UTC, Nadav Weizmann <nadav....@gmail.com> wrote:
Hey Christian,
Thanks for your quick reply.

I simply want to write my own unit-tests, i wanna have ORM models, with
internal relationships between them and write tests for it (not to mention
proprietary methods which uses them...).

For some reason, this was not as easy task as it usually is with other
similar technologies...



On Tue, Oct 6, 2015 at 5:34 PM UTC, Christian Melchior <he...@realm.io> wrote:
Hi Nadav

What specifically do you want to test. This functionality is already covered by the unit tests by Realm itself, so you shouldn't need to write tests for it in your app. Also many-to-many references are first-class citizens in Realm, so they behave just like normal object references.

--
Christian Melchior
Senior Android Developer


On Tue, Oct 6, 2015 at 3:04 PM UTC, Nadav Weizmann <nadav....@gmail.com> wrote:
Hey,

Anyone has a good, solid example of testing models and relationships? (specifically many-to-many).

I find it hard to setup tests, especially without robolectric.

Thanks
--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/3415f349-aefb-418e-afce-a722bb081021%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:128156143-1990#}
Reply all
Reply to author
Forward
0 new messages