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. Changing button text color in various states (down, disabled etc)

I would like to vary the text color of a custom button that I am
making depending on which state it is in (enabled, disabled, state
pressed).  I know how to use an XML file to describe the different
drawables that I need for the different states like so:

In the drawables folder I create this custom_button.xml file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="">
                android:state_pressed="false" />
                android:state_pressed="true" />
                android:state_enabled="false" />

However, adding android:textColor to each item totally makes the
button style invalid.  Even if I create a style in the themes.xml
file, I only get a single android:textColor like so:

<?xml version="1.0" encoding="utf-8"?>
        <style name="CustomButton" parent="@android:style/Widget.Button">
        <item name="android:gravity">center_vertical|
        <item name="android:textColor">#FF0000ff</item>
        <item name="android:textSize">14sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:background">@drawable/custom_button</item>
        <item name="android:focusable">true</item>
        <item name="android:clickable">true</item>

How do I style the textColor when pressed and textColor when disabled
states without resorting to a subclass of a Button?


2. Handset recommendation for outdoor use (screen readability)?

I have a Nexus One with a Clarivue anti-glare screen protector.  It
makes a big difference for usability outside.  It's still pretty hard
to use in direct sunlight, but it's fine as long as I can stand in the



3. Detect Wifi Enabled/Disabled

4. ListView scrolling past top and bottom

5. Loadable Kernel Module

6. No underline for texts candidates in html before committing

7. double tap zoom on Google maps