0

I have an SQLite database that gets created when the app starts. Currently, in my automated tests, I am deleting the existing database and recreating it every time - a very time consuming process on an emulator to redo for every database test. How can I improve my test design to speed this up?

I want to create this .db file once and reuse it for my automated tests. Unfortunately, extracting this file is a painful process that has to be manually done every time my initial data changes. I am in the middle of initial development, so my app's initial dataset is constantly changing.

Is there anyway I can automate this process a little better with Gradle?

ZakTaccardi
  • 12,212
  • 15
  • 59
  • 107

1 Answers1

0

You can create your db file once and include it as an asset. This way it will be filled when your app is installed for test.

Have a look at Ship an application with a database for more information.

Even when your database will change, your tests will be depending on the same dataset. And when you are done with initial testing, you have an environment artifact for regression testing.

Community
  • 1
  • 1
dmaij
  • 1,017
  • 7
  • 15
  • thanks. This is what I want to do - but my DB file is created via my `SQLiteOpenHelper`'s `onCreate()` method. So I cannot include it without running my Android application at least once. A bit of a dependency issue. – ZakTaccardi Apr 02 '15 at 17:47
  • Actually, you can. If you run it just once and use adb pull, you have your database which can be altered using SQLite manager for instance. abd push it back for testing. – dmaij Apr 04 '15 at 20:37