realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

Document how to run integration tests with Realm

Open joseprl89 opened this issue 7 years ago • 3 comments

Goal

To document how to write integration tests using Realm.

Expected Results

Developers to easily get up and running an integration test.

Why

I'm looking to build a PoC using a ports and adapters setup, where I have a set of interfaces that another module will implement. This module should ideally be isolated and have as single responsibility the implementation of the port.

In order to prove that this library works, I'd like to write integration tests where the adapters are executed against Realm, and I can assert it behaves as any other adapter should.

joseprl89 avatar Aug 25 '18 11:08 joseprl89

If Realm is isolated inside a module and the module just exposes standard interfaces I don't see any reason why it shouldn't "just work" like any other integration test setup.

But maybe I'm not fully understanding what you are trying to do?

cmelchior avatar Aug 27 '18 08:08 cmelchior

@cmelchior sorry it wasn't clear enough, I spent some more time over the weekend and manage to get the tests I was looking for.

To be more concrete, my proposal would add to this [section(https://realm.io/docs/java/latest/#testing-and-debugging):

  • How to mock Realm (already had a sample here) ** Add as a caveat that you shouldn't mock classes you don't own, with a link to something along the lines of this.
  • How to run an integration test where you prove your code + Realm mets the requirements you have. ** In the testing samples, only unit tests and espresso test are presen

And to add in the test samples an example of an instrumentation test. I will do a PR for this.

joseprl89 avatar Aug 27 '18 14:08 joseprl89

@cmelchior run into some issues I'm afraid due to my AS being newer than the version used to maintain this project (3.1.4):

https://github.com/realm/realm-java/pull/6129

Could you look into running the tests? I think it should be fine but unfortunately didn't manage to test it properly :(

joseprl89 avatar Aug 27 '18 15:08 joseprl89