SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
29.
DroidKaigi 2015/04/25 @cattaka_net
SqlteOpenHelperの差し替え
プロダクションコード
public class OpenHelperFactory {
static OpenHelperFactory INSTANCE = new OpenHelperFactory();
public static OpenHelperFactory getInstance() {
return INSTANCE;
}
@Override
public OpenHelper createOpenHelper(Context context) {
return new OpenHelper(context);
}
}
テスト用のダミー
public class DummyOpenHelperFactory extends OpenHelperFactory {
public OpenHelper createOpenHelper(Context context) {
Context c = new RenamingDelegatingContext(context, "test_");
return new OpenHelper(c);
}
}
テストのときは
ここをダミーに差し替える