Jon
Jon

Reputation: 3194

Using Eclipse to test intents in android

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:

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?

Upvotes: 1

Views: 347

Answers (4)

Joe Malin
Joe Malin

Reputation: 8641

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).

Upvotes: 2

Boris Strandjev
Boris Strandjev

Reputation: 46943

I have asked around and a friend of mine told me a list of tools you can use to functionally test android application.

Freeware:

Commercial products:

He recommended FoneMonkey as good enough tool for functional testing. I don't think you can implement functional tests for Android Application using only Android library testing tools without any third party extensions.

Upvotes: 2

Frank Cheng
Frank Cheng

Reputation: 6186

You cam use adb shell am to open a activity or send broadcast.
For example. You want to open a activity, the component of it is "com.test/.MainActivity". then you just need to type "adb shell -n com.test/.MainActivity".

Upvotes: 2

hqt
hqt

Reputation: 30276

If you like to test your database, you can open File Explorer of ADT, save your database to other place and open by other database reader. (such as: SQLite Database Browser)

Upvotes: 1

Related Questions