-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dexcache == null error #12
Comments
Are you sure? I can't see any changes in the code path that would suggest it should not fail anymore. I've added a pull request that updates the AppDataDirGuesser. It was out-of-date for any Android version 4.3+. With that it should be fine. |
@sek please try 1.4. |
I'm getting new errors in 1.3 and 1.4 =/ I pushed a simple demo project to github for reference: https://github.com/sek/MockitoOnAndroidDemo To clone and run tests:
It should also open smoothly in Android Studio 1.3 for editing. With dexmakerVersion == 1.2All tests pass. Note that if this problem is fixed, DexmakerIssue12Test.testMockAndroidObject() should fail with "expected an Exception" message. With dexmakerVersion == 1.3com.stankurdziel.mockitodemo.DexmakerIssue12Test > testMockAndroidObject[Nexus_5_API_21_x86(AVD) - 5.0.1] FAILED com.stankurdziel.mockitodemo.DexmakerIssue12Test > testMockAndroidObjectWorkAround[Nexus_5_API_21_x86(AVD) - 5.0.1] FAILED With dexmakerVersion == 1.4com.stankurdziel.mockitodemo.DexmakerIssue12Test > testMockAndroidObject[Nexus_5_API_21_x86(AVD) - 5.0.1] FAILED com.stankurdziel.mockitodemo.DexmakerIssue12Test > testMockAndroidObjectWorkAround[Nexus_5_API_21_x86(AVD) - 5.0.1] FAILED |
Will look into it tonight. |
Are there updates on this issue? We simply don't get mockito working on Android Devices (API21). We're trying to mock Classes. We tried it with 1.4, no Chance.. |
Hi @mjohenneken , I think we are on API22 now, but pretty sure it worked fine on API21 also - just an inconvenience to have to have that line in your setUp() for every test mocking android classes. -Stan |
I figured out that those dependencies make me able to write tests with Mockito, JUnit4 and Espresso on the Android Device. I had to add dexmaker-dx as dependency.
|
@mjohenneken Thanks! Adding the |
This is still a issue when trying to run local (non-android) tests in an android library module. It is working for application modules. In the local tests the DexmakerMockMaker should not be used at all. My current workaround is to provide a custom Mockito PluginSwitch which causes Mockito to use the default MockMaker. |
Hey guys I found a workaround for this that works: https://comadeblog.wordpress.com/2013/11/12/dexcachenull-for-mockito-on-robolectric/comment-page-1/ Basically use 1.9 version of Mockito:
|
@AnthonyUccello that worked for me. Can you guys fix this please however so we can use the latest 2.0 version? |
@MatFl or anyone, Many thanks! |
Newer versions of mockito (I think since mockito 2.6) support android out of the box. You can remove all the dexmaker dependencies and add the mockito-android instead. Check out the android-boilerplate project for an example: https://github.com/ribot/android-boilerplate/blob/master/app/build.gradle |
@MatFi |
This issue from the old google code project: https://code.google.com/p/dexmaker/issues/detail?id=2 is still valid as of the released 1.2 version
However, I verified that it has been fixed in the current github repository (last commit March 12th 2015 - ca74669):
It would be nice to have a 1.3 release so that we can take the workaround lines out of the test setUp() methods:
System.setProperty("dexmaker.dexcache", getContext().getCacheDir().getPath());
Thanks!
The text was updated successfully, but these errors were encountered: