Closed Akramhussain4 closed 5 years ago
If you run unit tests on local jvm you don't have access to the Context so you can't use Paper directly and must mock its methods. If you run instrumentation tests you should call Paper.init() prior running any tests )in your setUp method).
I am running unit tests in Android Studio and I can't pass the context of a unit test class. I tried calling Paper.init() with the context of unit class in setUp method but it just doesn't take that context or the mocked context.
I am running unit tests in Android Studio and I can't pass the context of a unit test class. I tried calling Paper.init() with the context of unit class in setUp method but it just doesn't take that context or the mocked context.
Like he said, for a local jvm unit test you gotta mock the init() method from Paper.class. But since this call is static you can try using PowerMockito to mock it.
io.paperdb.PaperDbException: Paper.init is not called when I try to run code for unit testing using mockito. I am unable to initialize paper in UnitTesting class.