当我运行我的测试时,所有的东西都保存在我的 sqllite 数据库中,所以我想在我的 Junit 测试完成后回滚我的 Android 数据库,这可能吗?
protected void setUp() throws Exception {
super.setUp();
Log.i(TAG, Utils.getMethodName() + "entry ");
sdbApp = (SdbApplication) getContext().getApplicationContext();
mContext = getContext();
mProvider = new SdbContentProvider();
mProvider.attachInfo(mContext, null);
mMockContentResolver = new MockContentResolver();
// Create the authority for the URI, by removing the 'content://' and
// any
// '/' or path part after that.
String authority = SpaceDB.CONTENT_URI.toString().substring(10);
int pos = authority.indexOf('/');
if (pos > -1) {
authority = authority.substring(0, pos);
}
mMockContentResolver.addProvider(authority, mProvider);
authority = FolderDB.CONTENT_URI.toString().substring(10);
pos = authority.indexOf('/');
if (pos > -1) {
authority = authority.substring(0, pos);
}
mMockContentResolver.addProvider(authority, mProvider);
this.setContext(new IsolatedContext(mMockContentResolver, mContext));
Thread.sleep(5000);
}
这不应该IsolatedContext
帮助我吗?