Most visited

Recently visited

Added in API level 1
Deprecated since API level 3

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>


此类在API级别3中已弃用。
应该使用ActivityInstrumentationTestCase2编写新的测试,这为配置被测活动提供了更多选项

此课程提供单一活动的功能测试。 测试活动将使用系统基础结构(通过调用InstrumentationTestCase.launchActivity())创建,然后您将能够直接操作您的活动。 大部分工作由setUp()tearDown()自动处理。

如果您更喜欢单独的单元测试,请参阅 ActivityUnitTestCase

Summary

Public constructors

ActivityInstrumentationTestCase(String pkg, Class<T> activityClass)

以非触摸模式创建 ActivityInstrumentationTestCase

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

创建一个 ActivityInstrumentationTestCase

Public methods

T getActivity()
void testActivityTestCaseSetUpProperly()

Protected methods

void setUp()

设置夹具,例如打开网络连接。

void tearDown()

在开始下一个测试之前,确保清理所有资源并收集垃圾。

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)

在非触摸模式下创建 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

ActivityInstrumentationTestCase

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

创建一个 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
异常

Protected methods

setUp

Added in API level 1
void setUp ()

设置夹具,例如打开网络连接。 在执行测试之前调用此方法。

Throws
异常

tearDown

Added in API level 1
void tearDown ()

在开始下一个测试之前,确保清理所有资源并收集垃圾。 覆盖此方法的子类应确保它们在重写方法的末尾调用super.tearDown()。

Throws
异常

Hooray!