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
Cannot mock Google Analytics Tracker class with Inline Mocks #1000
Comments
Since I tried using
|
Thank you for an excellent report with repository where we can reproduce the issue. 2 Mockito core developers became (are becoming) fathers this Spring so it might be a while when we have time to investigate this issue :) (ping @raphw). In the meantime, perhaps you can follow @tmurakami advice? Thanks a lot @tmurakami for jumping in and offering help! |
There should never be a verify error, I will look into this once I find the time! |
I think I have this "fixed" as I added an explicit check to Byte Buddy for inconsistent stack map frames. This seems to be a side-effect of using ProGuard in Android which destroys some metainformation in a way that the JVM can still run a method but that makes it practically impossible to instrument a class. The irony is that this destruction does not obfuscate a thing as it only removes the types of the Byte Buddy does however no longer throw a verifier error but a more descriptive error message. |
Closing this per above comment. Feel free to reopen if you are still running into this issue with a recent Mockito version (2.10.0+) |
Greetings,
I updated Mockito to 2.7.16 to use inline mocks for the seriously awesome feature to mock finals (thank you btw!) but found that the Google Analytics Tracker class wasn't mocking, where it was before without issue.
I found this post on the Mockito forum with the same problem, but I don't think the original reporter ever brought the issue to here.
I created a repo that can be used to reproduce the issue. You'll need Android Studio to be able to run it. The ExampleUnitTest class just tries to mock the com.google.android.gms.analytics.Tracker class and it fails right away. Here's the stack trace of that failure:
There's no hurry on this fix as we're not officially supporting analytics yet. I mostly just wanted to bring this to your attention as we'll need to look into this eventually and I'm sure there will be others trying to mock the Tracker. Let me know if you need more information or if there's anything I can do to help.
Thanks,
Mykaelos
The text was updated successfully, but these errors were encountered: