I currently have various AndroidTestCases
which use Mockito
and the module dexmaker-mockito
. I am now trying to add Robolectric
test cases using the robolectric plugin
.
I have everything running fine except that when I try to mock methods with no arguements I get an IllegalArgumentException
from Dexmaker
. Removing the dexmaker-mockito
dependency and using mockito version 1.9.0
instead of 1.9.5
causes the error to go away but causes all of my AndroidTestCases to fail. Is there anyway in gradle
to have dexmaker-mockito
exclude from my robolectric
test cases? Or does anyone know of any other way to run both android unit test and robolectric unit test from android studio?
Error:
java.lang.IllegalArgumentException at com.google.dexmaker.mockito.InvocationHandlerAdapter.invoke
Update
I tried gradle-android-test-plugin
and robolectric-gradle-plugin
but was unable to to get rid of the IllegalArguementException
without changing the version of mockitio
to 1.9.0
and removing dexmaker
, dexmaker-mockito
from my dependencies.
I tried the guide but was unable to get Android Studio to recognize my source directories without adding them to main or test source sets which break my build because robolectric is not compiled for those gradle tasks and I do not want it to be.
I ended up following the guide here this time the error disappeared when I ran the tests from command line but persisted when running from android studio which I found odd. Again changing the version of mockitio to 1.9.0 and removing dexmaker
, dexmaker-mockito
from my dependencies in my Android App removed the error. For now I will settle for not being able to run the unit tests from android studio until I find a better answer.