The next version of my app includes some changes to the database, which means I need to test how existing data is affected. On Windows, I would have a VM with snapshots to test upgrades. On Android, I have to install an old version, create data, and then test the upgrade. Is there a faster way?
-
1Yes, you can make backup of your old data and restore it as a snapshot (http://stackoverflow.com/questions/1510840/where-does-android-emulator-store-sqlite-database). Also you can generate your old data programmatically. – T D Nguyen Nov 04 '14 at 01:09
-
@NguyenDoanTung, I would accept this answer. I've managed to make a copy of the APK and database from the old version so that I can quickly set up my old version and test upgrades to the new. – NSouth Nov 04 '14 at 14:14
1 Answers
black-box testing is like what you have mentioned
developer testing can be done in multiple ways. One approach is described below
you can write a JUNT app which actually deals with 2 template database files loaded in assets.
- first database file should be of version1 schema filled with data
- second db file should be containing same data with version2 schema
The above 2 files can be created with tools like sqlite expert personal. And it is one time manual effort. Now you can write a JUNIT app that actually copies db1 to the data/data/database folder and then open it with your version2 database helper to get it upgraded. result of the upgraded database can be compared with template2 data using simple for loop iteration of all rows for all tables.
I have done it for apps based on large database and complex upgrade logic. One time effort to create template is worth in long run during development process.

- 1,883
- 1
- 17
- 26
-
This sounds like the best approach, but for a small app with only a few hundred users that I maintain in my scarce free time, I think something with less initial effort is what I'm looking for. – NSouth Nov 04 '14 at 14:13