realm-java
realm-java copied to clipboard
Unit tests should support global init
Fallout from #3457
Testing this is non-trivial since the Context is now saved in a system-wide Singleton that remains between unit tests.
We need to refactor to allow the following:
- Add tests for
Realm.init()not called - Don't require all unit tests to specifically require setting this.
A solution I think will work is:
-
Introduce a new
RealmUnitTestRunnerthat extendsAndroidJUnit4runner. It will be responsible for callingRealm.init(InstrumentationTarget.getTargetContext()) -
Add a protected
Realm.resetInit()method that allows specific unit tests to reset the state if needed.