Runtime exception while running robolectric 3.0 unit tests in Android studio 1.2 -


i running android unit tests using robolectric 3.0 , have run in runtime exception. tests pretty gives same exception.

java.lang.runtimeexception: java.lang.runtimeexception: should calling main thread!     @ org.robolectric.robolectrictestrunner$2.evaluate(robolectrictestrunner.java:244)     @ org.robolectric.robolectrictestrunner.runchild(robolectrictestrunner.java:188)     @ org.robolectric.robolectrictestrunner.runchild(robolectrictestrunner.java:54)     @ org.junit.runners.parentrunner$3.run(parentrunner.java:231)     @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:60)     @ org.junit.runners.parentrunner.runchildren(parentrunner.java:229)     @ org.junit.runners.parentrunner.access$000(parentrunner.java:50)     @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:222)     @ org.robolectric.robolectrictestrunner$1.evaluate(robolectrictestrunner.java:152)     @ org.junit.runners.parentrunner.run(parentrunner.java:300)     @ org.gradle.api.internal.tasks.testing.junit.junittestclassexecuter.runtestclass(junittestclassexecuter.java:86)     @ org.gradle.api.internal.tasks.testing.junit.junittestclassexecuter.execute(junittestclassexecuter.java:49)     @ org.gradle.api.internal.tasks.testing.junit.junittestclassprocessor.processtestclass(junittestclassprocessor.java:69)     @ org.gradle.api.internal.tasks.testing.suitetestclassprocessor.processtestclass(suitetestclassprocessor.java:48)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:35)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:24)     @ org.gradle.messaging.dispatch.contextclassloaderdispatch.dispatch(contextclassloaderdispatch.java:32)     @ org.gradle.messaging.dispatch.proxydispatchadapter$dispatchinginvocationhandler.invoke(proxydispatchadapter.java:93)     @ com.sun.proxy.$proxy2.processtestclass(unknown source)     @ org.gradle.api.internal.tasks.testing.worker.testworker.processtestclass(testworker.java:105)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:35)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:24)     @ org.gradle.messaging.remote.internal.hub.messagehub$handler.run(messagehub.java:360)     @ org.gradle.internal.concurrent.defaultexecutorfactory$stoppableexecutorimpl$1.run(defaultexecutorfactory.java:64)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:744) caused by: java.lang.runtimeexception: should calling main thread!     @ org.robolectric.shadows.shadowlooper.resetthreadloopers(shadowlooper.java:52)     @ org.robolectric.shadows.reset(shadows.java:1617)     @ org.robolectric.robolectric.reset(robolectric.java:22)     @ org.robolectric.internal.paralleluniverse.resetstaticstate(paralleluniverse.java:43)     @ org.robolectric.robolectrictestrunner$2.evaluate(robolectrictestrunner.java:233)     ... 34 more 

i have tried many suggested options such adding --rerun-tasks script parameters, uncheck "use in-process build" option in compiler -> gradle settings of android studio etc..but none of them have worked.

here sample of build.gradle dependency list:

dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     compile ('com.android.support:appcompat-v7:18.0.0'){         force = true     }     compile ('com.android.support:mediarouter-v7:18.0.0'){         force = true     }     compile 'com.google.android.gms:play-services:6.5.87'      testcompile 'junit:junit:4.12'      testcompile 'com.github.tomakehurst:wiremock:1.46'      testcompile 'org.bouncycastle:bcprov-jdk15on:1.50'      testcompile ('org.robolectric:robolectric:3.0-rc3'){         exclude group: 'commons-logging', module: 'commons-logging'         exclude group: 'org.apache.httpcomponents', module: 'httpclient'     }     testcompile 'org.robolectric:shadows-support-v4:3.0'     testcompile 'org.robolectric:shadows-httpclient:3.0'     testcompile 'org.robolectric:shadows-maps:3.0' } 

have spent many hours looking in no result. highly appreciate in regard.

thanks!


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -