The document describes tests for an SQLite database using the IconDao and SQLiteOpenHelper classes. It includes tests to find a specific icon by URL, and tests migrating the database schema from version 1 to version by replacing the SQLiteOpenHelper with a new version and verifying the updated column info.
1 of 28
Downloaded 47 times
More Related Content
SQLite 周りのテストをしよう
9. context = new RenamingDelegatingContext(
getContext(),
"test_"
);
helper = new TestterSQLiteOpenHelper(
context
);
16. public class IconSQLiteDaoTest extends DatabaseTestCase {
private IconDao iconDao;
@Override
protected void setUp() throws Exception {
super.setUp();
importData(FileType.Yaml, "IconSQLiteDaoTest");
iconDao = new IconSQLiteDao(getSQLiteDatabase());
}
@Override
protected SQLiteOpenHelper createSQLiteOpenHelper() {
return new TestterSQLiteOpenHelper(getDatabaseContext());
}
public void testFindByUrl() {
Icon icon = iconDao.findByUrl("http://a2.twimg.com/
profile_images/1039340061/face_normal.png");
assertEquals(1, icon.id.intValue());
assertEquals("http://a2.twimg.com/profile_images/1039340061/
face_normal.png", icon.url);
assertEquals(1307203506481L, icon.createdAt.longValue());