Skip to content

Most visited

Recently visited

navigation

ActivityInstrumentationTestCase

public abstract class ActivityInstrumentationTestCase
extends ActivityTestCase

java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ android.test.InstrumentationTestCase
         ↳ android.test.ActivityTestCase
           ↳ android.test.ActivityInstrumentationTestCase<T extends android.app.Activity>


This class was deprecated in API level 3.
new tests should be written using ActivityInstrumentationTestCase2, which provides more options for configuring the Activity under test

This class provides functional testing of a single activity. The activity under test will be created using the system infrastructure (by calling InstrumentationTestCase.launchActivity()) and you will then be able to manipulate your Activity directly. Most of the work is handled automatically here by setUp() and tearDown().

If you prefer an isolated unit test, see ActivityUnitTestCase.

Summary

Public constructors

ActivityInstrumentationTestCase(String pkg, Class<T> activityClass)

Creates an ActivityInstrumentationTestCase in non-touch mode.

ActivityInstrumentationTestCase(String pkg, Class<T> activityClass, boolean initialTouchMode)

Creates an ActivityInstrumentationTestCase.

Public methods

T getActivity()
void testActivityTestCaseSetUpProperly()

Protected methods

void setUp()

Sets up the fixture, for example, open a network connection.

void tearDown()

Make sure all resources are cleaned up and garbage collected before moving on to the next test.

Inherited methods

From class android.test.ActivityTestCase
From class android.test.InstrumentationTestCase
From class junit.framework.TestCase
From class junit.framework.Assert
From class java.lang.Object
From interface junit.framework.Test

Public constructors

ActivityInstrumentationTestCase

Added in API level 1
ActivityInstrumentationTestCase (String pkg, 
                Class<T> activityClass)

Creates an ActivityInstrumentationTestCase in non-touch mode.

Parameters
pkg String: ignored - no longer in use.
activityClass Class: The activity to test. This must be a class in the instrumentation targetPackage specified in the AndroidManifest.xml

ActivityInstrumentationTestCase

Added in API level 1
ActivityInstrumentationTestCase (String pkg, 
                Class<T> activityClass, 
                boolean initialTouchMode)

Creates an ActivityInstrumentationTestCase.

Parameters
pkg String: ignored - no longer in use.
activityClass Class: The activity to test. This must be a class in the instrumentation targetPackage specified in the AndroidManifest.xml
initialTouchMode boolean: true = in touch mode

Public methods

getActivity

Added in API level 1
T getActivity ()

Returns
T Returns the activity under test.

testActivityTestCaseSetUpProperly

Added in API level 1
void testActivityTestCaseSetUpProperly ()

Throws
Exception

Protected methods

setUp

Added in API level 1
void setUp ()

Sets up the fixture, for example, open a network connection. This method is called before a test is executed.

Throws
Exception

tearDown

Added in API level 1
void tearDown ()

Make sure all resources are cleaned up and garbage collected before moving on to the next test. Subclasses that override this method should make sure they call super.tearDown() at the end of the overriding method.

Throws
Exception
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.