java - Android Unit Test giving not mocked message for a Mockito stubbed method -


i've created following test method mock settings.secure , stub getstring method of 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 run test following error:

java.lang.runtimeexception: method getstring in android.provider.settings$secure not mocked. 

does have ideas?

settings.secure.getstring static method, mock(settings.secure.class) won't mock it. subclassing settings.secure , creating own static getstring won't here.

i'm not sure if there's reflection magic can out in case; none comes mind.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -