草庐IT

mockTelephonyManager

全部标签

android - 是否可以在 Android 中模拟系统服务

全部。我刚开始使用Mockito:)ContextmockContext=mock(Context.class);TelephonyManagermockTelephonyManager=mock(TelephonyManager.class);when(mockTelephonyManager.getNetworkCountryIso()).thenReturn("CN");when(mockContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mockTelephonyManager);当试图使用电话的esp