2 u014203484 u014203484 于 2017.08.29 19:38 提问

android单元测试怎样测如下函数

private String getSelectedConnectTypeKey() {
int re_way = Settings.System.getInt(getContentResolver(),"auto_recorder",0);
switch(re_way){
case 0:
return "null";
case 1:
return "all";
case 2:
return "part";
default:
return "invalidate";
}
}
如上函数,使用反射进行单元测试报错:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ContentResolver android.content.Context.getContentResolver()

求教怎莫办?
Csdn user default icon
上传中...
上传图片
插入图片