I've created the following test method where I mock Settings.Secure and stub the getString method of that class.
@Test
public void testIsDevicePostOwner() throws Exception {
String mockDeviceId = "2c3977ad-0867-49d6-aad8-c2762f373551";
Post mockedPost = mock(Post.class);
Settings.Secure mockedSecure = mock(Settings.Secure.class);
ContentResolver mockContentResolver = mock(ContentResolver.class);
when(mockedSecure.getString(mockContentResolver, Settings.Secure.ANDROID_ID)).thenReturn(mockDeviceId);
}
When I run the test I get the following error:
java.lang.RuntimeException: Method getString in android.provider.Settings$Secure not mocked.
Does anybody have any ideas?
Aucun commentaire:
Enregistrer un commentaire