For me it's unclear how to test my activity. My Activity works together with
my ContentProvider.
To test the functionality, I need to restore for every test a test scenario
(fixtures) on my SQLite database.
At the moment I'm doing this so:
*MainActivityTest#setUp*:
contentResolver = getInstrumentation().getContext().getContentResolver();
contentResolver.insert(MyContentProvider.CONTENT_URI__FIXTURES, new
ContentValues());
*MyContentProvider#insert:
* if (arg0.equals(CONTENT_URI__FIXTURES)) {
// reset database
dbHelper.onUpgrade(localDB, 0, 0);
DatabaseFixtures.insert(localDB);
localDB.close();
onCreate();
}
But it seem that this is not the right way, because the tests are very
unstable. I often get errors like "java.lang.IllegalStateException: database
not open".
How do you test your activities that communicate with a content provider?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en