Skip to main content
added 335 characters in body
Source Link
k3b
  • 7.6k
  • 1
  • 21
  • 31

Instead of verifying that

  • colum1 is name,
  • colum2 is birthday,
  • colum3 is ....

i would just test if these colums exist after upgrade.

To do this I would create an integration test that

  • starts with a databasefile which has old database version,
  • run the updater and then
  • execute a sql-select for every table with a all fields.

Example:

  • select name, birthday, telefonnumber from customer
  • select orderid, orderdate, customerid from order

Test-Success means there is no database-exception for unknown table or field.

[Update 2.2.2013] Unittesting the DatabaseOpenHelper (Unittest=Testing in isolation) would requre to test without a real database and verifying that the database update script is valid or at least contain all neccessary fields/tables. In my opinion this is to much work. Integration testing with a real database is much easier.

Instead of verifying that

  • colum1 is name,
  • colum2 is birthday,
  • colum3 is ....

i would just test if these colums exist after upgrade.

To do this I would create an integration test that

  • starts with a databasefile which has old database version,
  • run the updater and then
  • execute a sql-select for every table with a all fields.

Example:

  • select name, birthday, telefonnumber from customer
  • select orderid, orderdate, customerid from order

Test-Success means there is no database-exception for unknown table or field.

Instead of verifying that

  • colum1 is name,
  • colum2 is birthday,
  • colum3 is ....

i would just test if these colums exist after upgrade.

To do this I would create an integration test that

  • starts with a databasefile which has old database version,
  • run the updater and then
  • execute a sql-select for every table with a all fields.

Example:

  • select name, birthday, telefonnumber from customer
  • select orderid, orderdate, customerid from order

Test-Success means there is no database-exception for unknown table or field.

[Update 2.2.2013] Unittesting the DatabaseOpenHelper (Unittest=Testing in isolation) would requre to test without a real database and verifying that the database update script is valid or at least contain all neccessary fields/tables. In my opinion this is to much work. Integration testing with a real database is much easier.

Source Link
k3b
  • 7.6k
  • 1
  • 21
  • 31

Instead of verifying that

  • colum1 is name,
  • colum2 is birthday,
  • colum3 is ....

i would just test if these colums exist after upgrade.

To do this I would create an integration test that

  • starts with a databasefile which has old database version,
  • run the updater and then
  • execute a sql-select for every table with a all fields.

Example:

  • select name, birthday, telefonnumber from customer
  • select orderid, orderdate, customerid from order

Test-Success means there is no database-exception for unknown table or field.