Search code examples
androidsqlitejunit3

jUnit testing Database operations


I'm developing an Android application with database storage.

I want to test some classes that I use to access database.

I've found ActivityInstrumentationTestCase2 to test Activities but I haven't found anything to test classes.

How can I do that? I haven't used jUnit before.

Thanks.


Solution

  • I always use AndroidTestCases when writing unit tests for the Android platform. They provide access to a Context instance (if required), but otherwise work like the standard JUnit test class. You may also need to look at AndroidTestRunner to test your classes. There are some good tutorials out there; now that you know what to look for, I'm sure you can find them. Happy hunting! :D