-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Mockito 2 - Mocking final classes under androidTest does not work #1173
Comments
The final mock maker does not work on Android. |
thanks! Do you have it on the roadmap to make it work? |
There is no real possibility to make this work in Android at the moment as it lacks the instrumentation API on top of which we are operating. The Android VM is not a standard VM and only implements a subset of the Java specification. As long as Google does not choose to extend its JVM, I am afraid that this feature will not work. |
Hey, Thanks I try to apply dexopener + mockito-android but I fail, I create a new project follow instructions in readme, but i receive:
My gradle files: |
If you would like to run tests with adb, run "adb shell am instrument -w com.tdd.nilesh.opendex1.test/com.github.tmurakami.dexopener.DexOpenerAndroidJUnitRunner". |
Unfortunately Android Studio 2.3.1. does not allow to set InstrumentationRunner via Run/Debug Configuration it should be smart enough to pick it up on its own but unfortunately it is not. |
Could you remove your test settings from |
Regarding running tests from Android Studio runner: Regarding terminal: |
Running an independent test with using |
I run the test against Android Testing Support Library 1.0 and it works fine. |
When I created a sample app, everything started working fine, now I try to apply dexopener to the already existing project, I do the same steps but I get this response: |
Hello,
Default behaviour of mockito-core and mockito-android does not contain functionalities to mock final classes:
testCompile "org.mockito:mockito-core:+"
androidTestCompile "org.mockito:mockito-android:+"
To mock final classes under test/ package we can replace:
testCompile "org.mockito:mockito-core:+" with testCompile "org.mockito:mockito-inline:+"
To mock finall classes under androidTest we should create a file:
/mockito-extensions/org.mockito.plugins.MockMaker containing the value mock-maker-inline.
This soultion does not work. I still receive the same exception that final classes canot be mocked.
Cheers!
The text was updated successfully, but these errors were encountered: