Has anyone implemented robolectric 2.3 with couchbase-lite-android 1.02?

I have a project where I have implemented couchbase-lite-android, but it works very well. However, I tried to add Robolectric to work on adding component and component tests, but had no time to get the two to work together. I am currently getting the following problem.

DEBUG: download android assets from jar: C: \ Users \ brad.m2 \ repository \ org \ robolectric \ android-all \ 4.3_r2-robolectric-0 \ android-all-4.3_r2-robolectric-0.jar! / Permissions ...

java.lang.UnsatisfiedLinkError: no com_couchbase_touchdb_TDCollateJSON in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at com.couchbase.touchdb.TDCollateJSON.(TDCollateJSON.java:36)
at com.couchbase.lite.android.AndroidSQLiteStorageEngine.open(AndroidSQLiteStorageEngine.java:46)
at com.couchbase.lite.Database.open(Database.java:911)
at com.couchbase.lite.Manager.getDatabase(Manager.java:227)
at com.snapterm.core.models.transaction.TransactionsDb.initDatabase(TransactionsDb.java:61)
at com.snapterm.core.models.transaction.TransactionsDb.(TransactionsDb.java:49)
at com.snapterm.core.models.transaction.TransactionsDb.getInstance(TransactionsDb.java:41)
at com.snapterm.core.SnapTerm.onCreate(SnapTerm.java:42)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:164)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:430)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:236)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

      

I have failed to fix this error no matter how I manually try to load this library. I believe this is a current limitation with Robolectric finding native libraries, but I'm curious if anyone has tried these two together and made them successful.

+3


source to share


1 answer


I've never been able to implement Robolectric coverage for testing around Couchbase, however you can use Couchbase and Robolectric in the same project if you are using dependency injection using something like a dagger. What you need to do is define interfaces around all the Couchbase elements that you use, and in any of your application codes, when you need to use these aspects of Couchbase, you use the interface. Then, to get Robolectric to work, you implement test versions of the interfaces in a test unit.



In the last step, you use Dagger to inject real Couchbase classes into your main application module, and you inject test versions into the test application module. This will allow you to write tests around your code, mocking your database layer.

0


source







All Articles