If you want to mock the static method, use PowerMock
You will need to run PowerMockRunner and prepare the class for the test:
@PrepareForTest({Settings.Secure.class})
To taunt an object, you need to:
PowerMockito.mockStatic(Settings.Secure.class);
Then you can try:
when(Settings.Secure.getString(mockContentResolver, Settings.Secure.ANDROID_ID)).thenReturn(mockDeviceId);
Finally, you can check:
verifyStatic();
source
share