SQLite 周りのテストをしよう

5,044
-1

Published on

第 1 回 Android テスト祭りで SQ発表した資料

Published in: Technology, Art & Photos
0 Comments
12 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,044
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
45
Comments
0
Likes
12
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • SQLite 周りのテストをしよう

    1. 1. context = new RenamingDelegatingContext( getContext(), "test_");helper = new TestterSQLiteOpenHelper( context);
    2. 2. 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());
    3. 3. public class MigrationTest extends DatabaseTestCase { @Override protected SQLiteOpenHelper createSQLiteOpenHelper() { return new FixtureV1MigrationOpenHelper(getDatabaseContext()); } public void testV1Migration() { importData(FileType.Csv, "migrationTest"); ColumnInfo[] infos = loadColumnInfos("user"); assertEquals(5, infos.length); assertEquals("_id", infos[0].getName()); assertEquals("name", infos[1].getName()); assertEquals("weight", infos[2].getName()); assertEquals("image", infos[3].getName()); assertEquals("created", infos[4].getName()); replaceSQLiteOpenHelper(newFixtureMigrationOpenHelper(getDatabaseContext())); infos = loadColumnInfos("user"); assertEquals(6, infos.length);

    ×