所有.我是新手使用Mockito :)
Context mockContext = mock(Context.class);
TelephonyManager mockTelephonyManager = mock(TelephonyManager.class);
when(mockTelephonyManager.getNetworkCountryIso()).thenReturn("CN");
when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);
Run Code Online (Sandbox Code Playgroud)
当espresso测试尝试使用电话时,上述方法无效,它仍然返回系统网络国家ISO.有什么想法吗?谢谢!
| 归档时间: |
|
| 查看次数: |
1809 次 |
| 最近记录: |