7

I have a application with hundreds of unit test using robolectric, after I add Parse SDK in my Application Parse.initialize(this, "", ""); all test started to fail with error causing java.lang.VerifyError: Bad type on operand stack, although the application works without problem.

Edit: I am aware of workarounds to run my tests without Parse. I want to be able to run tests that use Parse framework.

The complete stack trace is showed bellow.

/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7532 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/lib/idea_rt.jar:/Applications/Android Studio.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/guilhermecastro/Library/Android/sdk/platforms/android-23/data/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/classes/test/enem/debug:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/classes/enem/debug:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric-annotations/3.1-SNAPSHOT/b766a056ea427a742dd79506bdbb63252393a1cf/robolectric-annotations-3.1-SNAPSHOT.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-auth/8.4.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-auth/8.4.0/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-library/1.3/4785a3c21320980282f9f33d0d1264a69040538f/hamcrest-library-1.3.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-commons/5.0.1/7b7147a390a93a14d2edfdcf3f7b0e87a0939c3e/asm-commons-5.0.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.google.android.apps.common.testing.accessibility.framework/accessibility-test-framework/2.1/c2d6267c3ad0435ddf9e27a94a0e0af4ca3fdfbb/accessibility-test-framework-2.1.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.4.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.4.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-measurement/8.4.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-measurement/8.4.0/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/5.0.1/2fd56467a018aafe6ec6a73ccba520be4a7e1565/asm-5.0.1.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.3.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.3.0/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.androidannotations/rest-spring-api/4.0-SNAPSHOT/437f51d0168f1fc7276228c632f40a580e4cd032/rest-spring-api-4.0-SNAPSHOT.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-vision/8.4.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-vision/8.4.0/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.jayway.awaitility/awaitility/1.7.0/e4fa7955cab67d880e4868a0795cce3498ea7bf2/awaitility-1.7.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.6.0/a0990e2e812ac6639b6ce955c91b13228500476e/jackson-annotations-2.6.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/shadows-core/3.1-SNAPSHOT/b82376c4080f576f9ae7dd8d5e69d4e9ad015e08/shadows-core-3.1-SNAPSHOT.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/labelledspinner-release/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/labelledspinner-release/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric/3.1-SNAPSHOT/6473b51558001a1f38d905947eff5108e90280cf/robolectric-3.1-SNAPSHOT.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-android/1.2.0/6ee2953ccf51ce72b6d548c30c4633b99eb4f9dd/bolts-android-1.2.0.jar:/Users/guilhermecastro/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.3.0/support-annotations-23.3.0.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.3.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.3.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.3.0/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/xmlpull/xmlpull/1.1.3.1/2b8e230d2ab644e4ecaa94db7cdedbc40c805dfa/xmlpull-1.1.3.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.parse/parse-android/1.13.0/58a7d54b6a4f28be11f0cecec93097eddf473e6f/parse-android-1.13.0.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.3.0/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.3/fd32786786e2adb664d5ecc965da47629dca14ba/commons-codec-1.3.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j/53.1/786d9055d4ca8c1aab4a7d4ac8283f973fd7e41f/icu4j-53.1.jar:/Applications/Android Studio.app/Contents/gradle/m2repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.4/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.4/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/cglib/cglib-nodep/3.1/aa83efbd1aedc4f26bdf00e7ea78191483f2c9b3/cglib-nodep-3.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.almworks.sqlite4java/sqlite4java/0.282/745a7e2f35fdbe6336922e0d492c979dbbfa74fb/sqlite4java-0.282.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-tree/5.0.1/1b1e6e9d869acd704056d0a4223071a511c619e6/asm-tree-5.0.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/shadows-support-v4/3.1-SNAPSHOT/48ece111d7d02dc991f2fa43ca427fb3cda211f0/shadows-support-v4-3.1-SNAPSHOT.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/answers/1.3.6/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/answers/1.3.6/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.springframework.android/spring-android-core/1.0.1.RELEASE/e68f0e8e4b636ee30c4de58953be38d9b72a5e3b/spring-android-core-1.0.1.RELEASE.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-ant-tasks/2.1.3/b09be554228d66d208e5fef5266844aacf443abc/maven-ant-tasks-2.1.3.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.8.0/7b456ca6b93900f96e58cc8371f03d90a9c1c8d1/ant-1.8.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/19.0-rc2/93e17f60bc524c2610b41c494bb829c11ca89436/guava-19.0-rc2.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.mikhaellopez/circularimageview/2.1.1/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.mikhaellopez/circularimageview/2.1.1/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.8.0/8b53ba16fa62fb1034da8f1de200ddc407c8381/ant-launcher-1.8.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/xpp3/xpp3_min/1.1.4c/19d4e90b43059058f6e056f794f0ea4030d60b86/xpp3_min-1.1.4c.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-tasks/1.4.0/d85884acf6810a3bbbecb587f239005cbc846dc4/bolts-tasks-1.4.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric-utils/3.1-SNAPSHOT/b52242aa999e3c7069f9e0ff573bf4ecbc8dec07/robolectric-utils-3.1-SNAPSHOT.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.androidannotations/androidannotations-api/4.0-SNAPSHOT/6df845decdeef73e5b631cdaa82306a6a03b199b/androidannotations-api-4.0-SNAPSHOT.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/8.4.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/8.4.0/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.thoughtworks.xstream/xstream/1.4.8/520d90f30f36a0d6ba2dc929d980831631ad6a92/xstream-1.4.8.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.3.0/jars/libs/internal_impl-23.3.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-all/1.10.19/539df70269cc254a58cccc5d8e43286b4a73bf30/mockito-all-1.10.19.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-util/5.0.1/7c8caddfbd0b2d7b844f8fcc75175b9cb9cf4724/asm-util-5.0.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk16/1.46/ce091790943599535cbb4de8ede84535b0c1260c/bcprov-jdk16-1.46.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.github.bumptech.glide/glide/3.7.0/9e9eeaf9948ee4d6c3ab354e8dc14368f16994a4/glide-3.7.0.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.objenesis/objenesis/2.1/87c0ea803b69252868d09308b4618f766f135a96/objenesis-2.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.0.3/fcacc35075d9c3114da4c4122b42d78786135c90/httpclient-4.0.3.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.10/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.10/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.6.3/142ce64dcd709a4b5f6e7d71305a31d3893d077/jackson-core-2.6.3.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.0.1/e813b8722c387b22e1adccf7914729db09bcb4a9/httpcore-4.0.1.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.5.5/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.5.5/res:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric-resources/3.1-SNAPSHOT/945b87482365c347080c5b78fd268f1bd8567bd4/robolectric-resources-3.1-SNAPSHOT.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.8/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.8/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.springframework.android/spring-android-rest-template/1.0.1.RELEASE/e132d929bd181941f79b0d63edafb8a86ae6fd33/spring-android-rest-template-1.0.1.RELEASE.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.6.3/5c4fcae53dd82e2c549b8322d78c6ff47c94c8a8/jackson-databind-2.6.3.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/design/23.3.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.3.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.3.0/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-analysis/5.0.1/e286fbee48efacb4e7c175f7948d9d8b2ab52352/asm-analysis-5.0.1.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.google.protobuf/protobuf-java/2.6.1/d9521f2aecb909835746b7a5facf612af5e890e8/protobuf-java-2.6.1.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.6.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.6.0/jars/classes.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/org.robolectric/shadows-httpclient/3.1-SNAPSHOT/6b20423f62a6afa8c8eaefa7735f13fa7599497c/shadows-httpclient-3.1-SNAPSHOT.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/com.ximpleware/vtd-xml/2.11/ee5bcf62c1acf76434ee9f1c67a840bafef72a6d/vtd-xml-2.11.jar:/Users/guilhermecastro/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/res:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/jars/classes.jar:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/sourceFolderJavaResources/test/enem/debug:/Users/guilhermecastro/Documents/appprova-android/app/build/intermediates/sourceFolderJavaResources/enem/debug:/Users/guilhermecastro/Documents/appprova-android/build/generated/mockable-android-23.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.appprova.core.activity.AnswerActivityTest,testWrongAnswer
Exception in thread "pool-3-thread-1" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/parse/ParsePinningEventuallyQueue.resume()V @20: putfield
  Reason:
    Type 'bolts/Task$TaskCompletionSource' (current frame, stack[1]) is not assignable to 'bolts/TaskCompletionSource'
  Current Frame:
    bci: @20
    flags: { }
    locals: { 'com/parse/ParsePinningEventuallyQueue' }
    stack: { 'com/parse/ParsePinningEventuallyQueue', 'bolts/Task$TaskCompletionSource' }
  Bytecode:
    0x0000000: 2ab6 0028 9900 1f2a b400 1a01 b600 2a57
    0x0000010: 2ab8 002b b500 1a2a b400 1a01 b600 2a57
    0x0000020: a700 0a2a b800 2bb5 001a 2ab7 000c 57b1
    0x0000030:                                        
  Stackmap Table:
    same_frame(@35)
    same_frame(@42)

    at com.parse.Parse.getEventuallyQueue(Parse.java:616)
    at com.parse.Parse.access$800(Parse.java:42)
    at com.parse.Parse$1.call(Parse.java:410)
    at com.parse.Parse$1.call(Parse.java:407)
    at bolts.Task$3.run(Task.java:249)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/parse/ParseQuery.checkIfRunning(Z)V @37: putfield
  Reason:
    Type 'bolts/Task$TaskCompletionSource' (current frame, stack[1]) is not assignable to 'bolts/TaskCompletionSource'
  Current Frame:
    bci: @37
    flags: { }
    locals: { 'com/parse/ParseQuery', integer, 'java/lang/Object' }
    stack: { 'com/parse/ParseQuery', 'bolts/Task$TaskCompletionSource' }
  Bytecode:
    0x0000000: 2ab4 0005 594d c22a b400 0499 000d bb00
    0x0000010: 2f59 1230 b700 31bf 1b99 000f 2a04 b500
    0x0000020: 042a b800 32b5 0003 2cc3 a700 084e 2cc3
    0x0000030: 2dbf b1                                
  Exception Handler Table:
    bci [7, 42] => handler: 45
    bci [45, 48] => handler: 45
  Stackmap Table:
    append_frame(@24,Object[#266])
    same_frame(@40)
    same_locals_1_stack_item_frame(@45,Object[#267])
    chop_frame(@50,1)


    at com.parse.OfflineObjectStore.getAsync(OfflineObjectStore.java:73)
    at com.parse.CachedCurrentUserController$5$1.then(CachedCurrentUserController.java:240)
    at com.parse.CachedCurrentUserController$5$1.then(CachedCurrentUserController.java:219)
    at bolts.Task$14.run(Task.java:796)
    at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
    at bolts.Task.completeAfterTask(Task.java:787)
    at bolts.Task.continueWithTask(Task.java:599)
    at bolts.Task.continueWithTask(Task.java:610)
    at com.parse.CachedCurrentUserController$5.then(CachedCurrentUserController.java:219)
    at com.parse.CachedCurrentUserController$5.then(CachedCurrentUserController.java:216)
    at com.parse.TaskQueue.enqueue(TaskQueue.java:69)
    at com.parse.CachedCurrentUserController.getAsync(CachedCurrentUserController.java:216)
    at com.parse.CachedCurrentUserController.getAsync(CachedCurrentUserController.java:105)
    at com.parse.ParseUser.getCurrentUserAsync(ParseUser.java:883)
    at com.parse.Parse$3.then(Parse.java:430)
    at com.parse.Parse$3.then(Parse.java:426)
    at bolts.Task$14.run(Task.java:796)
    at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
    at bolts.Task.completeAfterTask(Task.java:787)
    at bolts.Task.continueWithTask(Task.java:599)
    at bolts.Task.continueWithTask(Task.java:610)
    at com.parse.Parse.initialize(Parse.java:426)
    at com.parse.Parse.initialize(Parse.java:364)
    at com.appprova.core.app.AppProvaApplication.onCreate(AppProvaApplication.java:40)
    at com.appprova.core.app.AppProvaApplication_.onCreate(AppProvaApplication_.java:38)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:160)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:454)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:252)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:193)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:56)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:159)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)


Process finished with exit code 255
Guilherme Torres Castro
  • 15,135
  • 7
  • 59
  • 96
  • Vasiliy's answer is correct. Robolectric is helping to run Android tests on JVM but is not a panacea. Some things you have to test on real devices or, at least, emulators. As he suggested you should wrap Parse dependency from the entire application and, in this case, you can test app with mocked Parse. However if you want to test integration with Parse, it should be instrumental test – Eugen Martynov Apr 23 '16 at 06:38
  • Ok, reading comments below the answer I think I will give another anwer – Eugen Martynov Apr 23 '16 at 06:40

3 Answers3

4

I change run configuration like this: - VM options: -noverify - code coverage: choose coverage runner to JaCoCo.

These steps resolve the problem.

Houssin Boulla
  • 2,687
  • 1
  • 16
  • 22
0

To my best knowledge, when you run tests using Robolectric's test runner, it will instantiate you Application class and execute its onCreate() method.

Now, in that method you're initializing Parse, but Parse SDK probably depends on Android framework, but there is none - Robolectric substitutes part of Android classes with its own implementations, and leaves others unimplemented. This, probably, is the cause for the exception you observe.

You might try to use the workaround specified here and provide a "test" version of your Application subclass, which does not initialize Parse SDK (probably, you should mock all interactions with this SDK while unit-testing anyway).

Following question's edit:

If you take a look at this question, you will realize that this exception is probably thrown because Parse SDK was compiled against some classes which are "mocked" by Robolectric. In other words, dependency classes are found, but their bytecode is different from expected.

Now, you could go and try to find a workaround for this issue (which would be non-trivial at all), but I don't see any reason to do so. If I understand correctly, you want to unit test your application's integration with Parse, which is fine. However, you don't really need the actual Parse SDK in order to do that - you could (and IMHO should) mock it out. Otherwise, your unit test would depend on functionality of that SDK, which is generally a bad idea and would lead to "flaky" tests. If you mock this SDK for unit testing, then you don't really need to initialize it in Application's subclass, and my initial advice still holds.

Community
  • 1
  • 1
Vasiliy
  • 16,221
  • 11
  • 71
  • 127
  • The problem is not related with Robolectric unimplemented methods. – Guilherme Torres Castro Apr 22 '16 at 18:21
  • @GuilhermeTorresCastro, didn't say the problem related to unimplemented methods, but that the problem is that Parse SDK probably depends on Android framework classes, which aren't present when you run tests with Robolectric. Have you tried to provide "test" Application class as described in the link I provided? – Vasiliy Apr 22 '16 at 18:54
  • Using test application will work, but I will not be able to test my classes that use Parse, that's the role point of using Robolectric. And the problem is not related with **Android framework classes, which aren't present when you run tests with Robolectric**. – Guilherme Torres Castro Apr 22 '16 at 19:59
  • In all case I will edit my question to be clear what I really want. It's not very clear. – Guilherme Torres Castro Apr 22 '16 at 20:00
  • 1
    @GuilhermeTorresCastro, I think our understanding of "unit test" differs - in my opinion, unit tests should not depend on any external dependency (these dependencies should be mocked out), in which case my initial suggestion will still resolve your issue. Tests that exercise multiple modules or/and SDKs are referred to as "integration tests" and are usually run on actual devices or emulators, in which case you won't use Robolectric.... I edited the answer to reflect this new info. – Vasiliy Apr 22 '16 at 20:25
  • Yep I agree with you, your suggestion will work for every other test in my Application. But I need to create tests for classes that extends ParseObject and the test will fail because Parse is not initialized. And indeed I need to mock some aspects of Parse. This question is more theoretical (I want to know why the exception occur). And the test are fail in the Bolt library which is not a Android dependency. – Guilherme Torres Castro Apr 22 '16 at 20:39
  • I don't know how down voted this answer but it is correct – Eugen Martynov Apr 23 '16 at 07:00
0

One of the problems with Parse usage that you have to extend ParseObject. There are two approaches how to tackle it.

Interfaces for core objects

interface User{}

interface UserCreator {
    @NonNull
    User createUser();
}

And classes implementation in storage layer

public class ParseUser extends ParseObject implements User {}

public class ParseUserCreator {}

We had this approach in one project and I constantly was filling that it is complex and not convenient. After all, I found an article that proved my filling.

"Duplication" core objects class User{}

and in the storage layer

class ParseUser {
    public void fromUser(@NonNull final User user){}
    @NonNull
    public User toUser(){}
}

class Storage {
   @NonNull
   public User loadUser() {
       ParseUser user = ...;
       return 
   }
}

This approach I like much more, but, at the same time, I'm not confident it is the best approach. Both variants completely hide Parse from rest application that makes code cleaner and allows you replace Parse if you decided to go with another framework or library.

Happy coding!

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114