Most visited

Recently visited

Added in API level 1
Deprecated since API level 24

ActivityTestCase

public abstract class ActivityTestCase
extends InstrumentationTestCase

java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ android.test.InstrumentationTestCase
         ↳ android.test.ActivityTestCase
Known Direct Subclasses


此类在API级别24中已被弃用。
应使用Android Testing Support Library编写新的测试。

这是用于支持活动测试用例的通用代码。 有关更多有用的课程,请参阅ActivityUnitTestCaseActivityInstrumentationTestCase

Summary

Public constructors

ActivityTestCase()

Protected methods

Activity getActivity()
void scrubClass(Class<?> testCaseClass)

这个函数在tearDown()时间被各种TestCase实现调用,以清除任何类变量。

void setActivity(Activity testActivity)

设置被测试的活动。

Inherited methods

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

ActivityTestCase

Added in API level 1
ActivityTestCase ()

Protected methods

getActivity

Added in API level 1
Activity getActivity ()

Returns
Activity Returns the activity under test.

scrubClass

Added in API level 1
void scrubClass (Class<?> testCaseClass)

这个函数在tearDown()时间被各种TestCase实现调用,以清除任何类变量。 这样可以防止在测试用例创建非静态内部类(因此引用测试用例)并将其提供给其他人保留的情况下发生内存泄漏。

Parameters
testCaseClass Class: The class of the derived TestCase implementation.
Throws
IllegalAccessException

setActivity

Added in API level 1
void setActivity (Activity testActivity)

设置被测试的活动。

Parameters
testActivity Activity: The activity under test

Hooray!