I have recently created an Android application that allows users to add shopping items and lists to a database and need to test its functionality. I have found information on testing whether certain TextViews contain the correct strings etc but that’s about it.
I need to have a test project that actually adds food items and tests whether that was successful, I was thinking maybe:
- Moving to the desired Activity
- Filling out and submitting the form to add a shopping item
- Move to the Activity containing all food items and their details
- Check the item was added correctly
Is this possible to do using an Android test project in Eclipse? If not, are there any other useful tools available for this kind of testing?
Also, see android.testing.ActivityInstrumentationTestCase2<>. You can set up an Intent to be given to the activity under test using setActivityIntent(), then do getActivity() to start the activity under test. There are tutorials in the Developers Guide for learning how to use ActivityInstrumentationTestCase2.
Unfortunately, there doesn’t seem to be much documentation for setActivityIntent(), and my guess is that it doesn’t test intent filtering.
I think you should do it as unit tests. First ensure that your source Activity is issuing the correct intents by writing a test destination that simply logs all the incoming Intent data.
Then write unit tests for the destination, based on setActivityIntent(). You can also use
Robotium or MonkeyRunner (part of Android).