You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Realm directly makes harder to write automated tests. The current solution with Realm in memory requires appContext to run tests. That is why we have to write unit test as android Instrumented test. I've came to that instrumented tests are good for UI testing, not for unit testing. We cannot use tools like Powermock there. In addition assertion blocks in tests look complicated.
Solution
Add a new class (singleton?) Storage. Realm clients will use this object instead of Realm. It will have concrete methods for retrieving and storing objects. As a result the current realm clients will dependent on Storage object. We can mock Storage without any problem in unit tests without appContext. So we will be able to write simple unit tests.
The text was updated successfully, but these errors were encountered:
The Issue
Using Realm directly makes harder to write automated tests. The current solution with Realm in memory requires appContext to run tests. That is why we have to write unit test as android Instrumented test. I've came to that instrumented tests are good for UI testing, not for unit testing. We cannot use tools like Powermock there. In addition assertion blocks in tests look complicated.
Solution
Add a new class (singleton?) Storage. Realm clients will use this object instead of Realm. It will have concrete methods for retrieving and storing objects. As a result the current realm clients will dependent on Storage object. We can mock Storage without any problem in unit tests without appContext. So we will be able to write simple unit tests.
The text was updated successfully, but these errors were encountered: