You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Mockito.spy(handler) the mQueue member variable is not copied over the to spy object.
Mockito :org.mockito:mockito-android
Mockito version used: 3.0.0
Sample:
Handler preHandler = new Handler(testApplication.getMainLooper());
spyHandler = spy(preHandler);
^ The preHandler has a mQueue variable set but the spyHandler does not.
When going through source code I noticed that the fields returned from Handler.class.getDeclaredFields() differs from API 28+ and API < 28.
This causes the org.mockito.internal.util.reflection.LenientCopyTool#copyValues to fail to copy the mQueue variable from the spiedInstance on API 28+
It's important for the the mQueue to be copied as well since it's not null checked in the Handler class final methods.
The text was updated successfully, but these errors were encountered:
When using Mockito.spy(handler) the mQueue member variable is not copied over the to spy object.
Mockito :org.mockito:mockito-android
Mockito version used: 3.0.0
Sample:
Handler preHandler = new Handler(testApplication.getMainLooper());
spyHandler = spy(preHandler);
^ The preHandler has a mQueue variable set but the spyHandler does not.
When going through source code I noticed that the fields returned from Handler.class.getDeclaredFields() differs from API 28+ and API < 28.
This causes the org.mockito.internal.util.reflection.LenientCopyTool#copyValues to fail to copy the mQueue variable from the spiedInstance on API 28+
It's important for the the mQueue to be copied as well since it's not null checked in the Handler class final methods.
The text was updated successfully, but these errors were encountered: