誰でも問題を解決できます:ormliteを使用するAndroidアプリをテストする方法は?
dao からモックを作成する方法を知りたいです。このコードは私にdaoを取得します
public Dao<Account, Integer> getAccountDao() throws SQLException {
if (accountDao == null) {
accountDao = getDao(Account.class);
}
return accountDao;
}
私のテスト アクティビティは次のようになります。
public class OrmActivity extends OrmLiteBaseActivity<DatabaseHelper> {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initUi();
initUiListeners();
RuntimeExceptionDao<Account, Integer> accountDao = getHelper().getAccountDataDao();
Account account = new Account();
account.setName("name");
account.setPassword("password");
accountDao.create(account);
}
テスト用に別のデータベースを作成したくありません。私はモックを使いたいと思っています。
よろしくお願いします