Trying to use mockito in my AndroidTestCase. I added the dependencies to the build.gradle:
final DEXMAKER_VERSION = \'1.2\'
dependencies {
// ...
an
Its a bug in dexmaker for which I have submitted a fix: https://github.com/crittercism/dexmaker/pull/24
For me the solution was to use the Method Mockito.mock()
for each Mocking Object instead of using MockitoAnnotations.initMocks(this);
So for example:
public class HomePresenterTest {
private Repository repository;
private HomePresenter presenter;
@Before
public void before() {
repository = mock(Respository.class);
presenter = new HomePresenter(repository);
}
//Your tests
}
I've created an issue there https://github.com/mockito/mockito/issues/392 Original answer with hotfix there https://stackoverflow.com/a/36642606/1224247
You could try to replace
MockitoAnnotations.initMocks(this);
with this
System.setProperty("dexmaker.dexcache", getContext().getCacheDir().getPath());
It works for me. See ref here