public abstract class
ActivityInstrumentationTestCase2
extends ActivityTestCase//繼承自ActivityTestCase類(lèi)
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.
該類(lèi)提供單獨(dú)的activity的功能測(cè)試.在測(cè)試項(xiàng)目下的該activity能夠使用系統(tǒng)基類(lèi)(調(diào)用:InstrumentationTestCase.launchActivity())并且你能夠直接操作你自己的Activity的。
You can run any test method on the UI thread (see UiThreadTest
).//你能夠在UI thread上跑任何的測(cè)試方法
You can inject custom Intents into your Activity (see setActivityIntent(Intent)
).//你能夠在你的Activity注入自定義的Intents(該描述意味著允許跳轉(zhuǎn))
This class replaces ActivityInstrumentationTestCase
, which is deprecated. New tests should be written using this base class.//該類(lèi)替代ActivityInstrumentationTestCase
, 該類(lèi)現(xiàn)在不建議使用挺据。新的測(cè)試集應(yīng)該使用該基礎(chǔ)類(lèi)磨隘。
If you prefer an isolated unit test, see ActivityUnitTestCase
.//如果你更喜歡一個(gè)獨(dú)立的單元測(cè)試,請(qǐng)參見(jiàn)ActivityUnitTestCase
Summary:
Public Constructors:
ActivityInstrumentationTestCase2(String pkg, Class<T> activityClass)
//This constructor was deprecated in API level 8. use ActivityInstrumentationTestCase2(Class)
instead(在高于API level 8后,該構(gòu)造方法被下方的方法取代了)
ActivityInstrumentationTestCase2(Class<T> activityClass)
//Creates an ActivityInstrumentationTestCase2.
Public Methods:
T
getActivity()Get the Activity under test, starting it if necessary.//獲取在測(cè)試下的Activity嗅定,如果必要的話可以啟動(dòng)
void
setActivityInitialTouchMode(boolean initialTouchMode)Call this method before the first call to getActivity()
to set the initial touch mode for the Activity under test.//在第一次調(diào)用 getActivity()
方法前可以調(diào)用該方法去初始化測(cè)試下Activity的TOUCH模式
void
setActivityIntent(Intent i)Call this method before the first call to getActivity()
to inject a customized Intent into the Activity under test.//在第一次調(diào)用 getActivity()
方法前可以調(diào)用該方法去注入測(cè)試下Activity的自定義的INTENT
Protected Methods
void
runTest()Runs the current unit test.
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.