-
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
mockStatic PendingIntent got NPE #168
Comments
Hey @paulhu0819 , thanks for reporting this bug. I have successfully reproduced it and going to work on your fix considering your suggestions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to use
mockStatic
to mock PendingIntent class in my test but it got NPE immediately after calledstartMonitoring()
.Code:
Logs:
I have looked into the NPE, the problem is that
InlineStaticMockMaker
usesHashMap
to store mock object data that will call to realPendingIntent.hascode()
when trying to put mockPendingIntent
object as aHashMap
key.To solve the NPE, I suggest
InlineStaticMockMaker
may use MockMap likeInlineDexmakerMockMaker
to store mock object data safely.dexmaker-mockito-inline-extended/src/main/java/com/android/dx/mockito/inline/InlineStaticMockMaker.java
The text was updated successfully, but these errors were encountered: