Android Functional Testing (testing multiple activities)

by Rick » Fri, 17 Apr 2009 23:48:08 GMT

Sponsored Links
 I've been exploring the Android test package and I'm very confused on
how to implement functional testing for endpoint-to-endpoint.

Consider the example below, I have 4 activities:
1. A Contact List Activity
2. A View Contact Activity
3. An Add/Edit Contact Activity
4. A Sync Contact List activity

I want to automate a few tests that will go through multiple test
cases simulating a user experience:
the add contact activity,
entering data, saving it, going back to the list activity, and
verifying the new contact was saved properly.

As I understand it, ActivityInstrumentationTestCase<T extends
Activity> and ActivityUnitTestCase<T extends Activity>, are only
useful for testing single activity functionality.

But what if I need to switch between 2 or more activities inside a
single functional test case?

Any help would be greatly appreciated.


Android Functional Testing (testing multiple activities)

by z » Sat, 18 Apr 2009 01:41:37 GMT



Sponsored Links

Android Functional Testing (testing multiple activities)

by Rick » Wed, 29 Apr 2009 00:36:33 GMT

 Android functional testing across multiple activities:

Since no one has really shown how to do this, and Android really only
shows us testing a single activity,
testing more complex applications will need cross-activity testing.
How to do it?

1. Use InstrumentationTestCase
2. Use an ActivityManager to maintain the scope of the application,
allowing you to grab the activity you want.
3. Use Instrumentation to put the application in the desired state
4. Most importantly, make sure to clean up after your test, other wise
it will hang.

All android testing runs through the setUp and TearDown before each
test. So if you have a test class with 5 tests,
it will run through the set up and tear down before each test.

You might be able to get around this by implement the @BeforeClass and
@AfterClass for a global setUp and TearDown
that can be spread across the test suite, I haven't explored that yet.
Hope this helps anyone looking for this.


Android Functional Testing (testing multiple activities)

by zlu » Wed, 29 Apr 2009 01:51:58 GMT


Thanks so much for posting your findings. They are helpful.


On Apr 28, 9:36am, Rick <> wrote:

Other Threads

1. Instructions to install Android on Netbook


On Mon, Jan 11, 2010 at 5:48 AM, Jaswinder Singh Rajput <

> website: 

2. android.backup package

I would like to use this package to back-up my app's database filles.
I was looking at the source for the User Dictionary Provider when I
noticed that it was using it.

Why is it not exposed in the public API and what are the plans in the
short term with it?

3. Launch updated emulator?

4. Service callback to Activity

5. Unable to connect to internet from emulator

6. Catching an action without setting an intent filter?

7. A good place to start learning Java?