Two of my JUnit tests against my app pass when I run them separately but 
fail when run consecutively.

The two tests run through the following sequence of actions:

*Test 1:*

   1. 
   
   Insert a single row to the database.
   
   This all occurs within the app using getContentResolver().insert().
   2. 
   
   Clean up the test.
   
   In particular, I delete the database using 
   context.deleteDatabase(DB_NAME);.
   
*Test 2:*

   1. 
   
   Insert multiple rows to the database.
   
   This again occurs within the app using multiple calls to 
   getContentResolver.insert(). The data inserted to the database includes 
   the data for the single row from Test 1. When this row of data is reached 
   in test 2, the test fails.
   
>From what I can tell, the ContentProvider in Test 2 still "sees" the data 
added during Test 1. I suspect this is due to my method of cleaning up the 
test. I verified with adb shell that the database file is deleted when Test 
1 cleans up and that it is recreated when Test 2 starts.

How do I correctly clean up the first test so that the second test doesn't? 
I guess I could split the two test methods into two separate classes. Even 
if this works, it means that I will have to split up other classes with 
even more test methods that experience the same issue. Does anyone have 
other suggesions?

Code Guru

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to