我正在使用 ProviderTestCase2 超类测试数据库。这是我的代码片段:
public class MyProviderTest extends ProviderTestCase2<MyProvider>{
private static MockContentResolver resolver;
private static IsolatedContext context;
public MetaDataProviderTest() {
super(MyProvider.class, Provider.AUTHORITY);
}
@Override
protected void setUp() throws Exception {
try{
super.setUp();
resolver = getMockContentResolver();
} catch(Exception e){
}
}
}
public void testfirst(){
Cursor cursor = resolver.query(ProviderContract.Channels.CHANNEL_URI,null,null,null,null);
....
}
}
当我调试上面的代码时,我得到了传递的结果。当我运行它时,我得到 Null 光标,暗示没有像通道这样的表。请帮助解决这个问题。我哪里做错了?