InstrumentationTestRunner 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
This class is obsoleted in this android platform
Instrumentation,針對 Android 套件 (應用程式) 執行各種類型的 junit.framework.TestCase。
[Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)]
[System.Obsolete("This class is obsoleted in this android platform")]
public class InstrumentationTestRunner : Android.App.Instrumentation
[<Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)>]
[<System.Obsolete("This class is obsoleted in this android platform")>]
type InstrumentationTestRunner = class
inherit Instrumentation
- 繼承
- 屬性
備註
Instrumentation,針對 Android 套件 (應用程式) 執行各種類型的 junit.framework.TestCase。
<div class=“special reference”><h3>Developer Guides</h3>
如需應用程式測試的詳細資訊,請參閱 測試 開發人員指南。
</div>
<h3>一般使用量</h3><ol><li>Write junit.framework.TestCases,針對套件中的類別執行單元、功能或效能測試。 這些通常是子分類來源:<ul><li>android.test.ActivityInstrumentationTestCase2</li><>android.test.ActivityUnitTestCase<><>android.test.AndroidTestCase<><>android.test.ApplicationTestCase<><>android.test.InstrumentationTestCase<><>android.test.ProviderTestCase<><>android.test.ServiceTestCase<><>android.test.SingleLaunchActivityTestCase<><><> set android:targetPackage the attribute of <instrumentation> the element in the test package's manifest. 您應該將屬性值設定為受測目標應用程式的套件名稱。
<li>使用 「adb shell am instrumentation -w」 執行檢測,不含選擇性自變數,以執行所有測試(效能測試除外)。
<li>使用 「adb shell am instrumentation -w」 執行檢測,並使用自變數 '-e func true' 來執行所有功能測試。 這些是衍生自 android.test.InstrumentationTestCase的測試。
<li>使用 「adb shell am instrumentation -w」 執行檢測,並使用自變數 '-e unit true' 來執行所有單元測試。 這些測試 不是衍生自 android.test.InstrumentationTestCase 的測試(且不是效能測試)。
<li>使用 “adb shell am instrumentation -w” 執行檢測,並將自變數 '-e class' 設定為執行個別 junit.framework.TestCase。
</ol><p/><b>執行所有測試:</b> adb 殼層 am instrumentation -w com.android.foo/android.test.InstrumentationTestRunner p/<>b 執行所有小型測試:</b> adb shell am instrumentation -w -e size small com.android.foo/android.test.InstrumentationTestRunner<> p/<>b<>執行所有中型測試:</b> adb 殼層 am instrumentation -w -e size medium com.android.foo/android.test.InstrumentationTestRunner <p/><b>執行所有大型測試:</b> adb 殼層 am instrumentation -w -e size large com.android.foo/android.test.InstrumentationTestRunner p/<>b<Filter test run to tests with given annotation:>/b< adb shell am instrumentation -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner ><p/> If used with other options, the resulting test run will contain the union of the two options. 例如,“-e size large -e annotation com.android.foo.MyAnnotation” 只會使用 LargeTest 和 “com.android.foo.MyAnnotation” 註釋來執行測試。
<p/>b 篩選測試執行至沒有<:>/b adb 殼層 am instrumentation -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner <p /><b>執行 單一 testcase:</b> adb shell am instrumentation -w -e class com.android.foo.Foo.FooTest com.android.foo/android.test.InstrumentationTestRunner <p/b 執行單一測試:>/b<><><>adb Shell am instrumentation -w -e class com.android.foo.Foo.Foo#testFoo com.android.foo/android.test.InstrumentationTestRunner <p/><b>執行多個測試:</b> adb Shell am instrumentation -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner <p/b 在 java 套件中執行所有測試:>/b<><>adb Shell am instrumentation -w -e package com.android.foo.subpkg com.android.foo/android.test.InstrumentationTestRunner p/<b Including performance tests:>/b< adb shell am instrumentation -w -e perf true com.android.foo/android.test.InstrumentationTestRunner ><p/><>b To debug your tests, set a break point in your code and pass:</b> -e debug true <p/b To run in 'log only' mode>/b<><><>-e log true 此選項會載入並逐一查看所有測試類別和方法,但會略過實際的測試執行。 適用於快速取得檢測命令所要執行之測試的資訊。
<p/><b>若要產生 EMMA 程式代碼涵蓋範圍:</b> -e 涵蓋範圍 true 注意:這需要經過 emma 檢測的組建。 根據預設,程式代碼涵蓋範圍結果檔案會儲存在 /data/<app>/coverage.ec 檔案中,除非覆寫 coverageFile 旗標 (請參閱下方) <p/><b> 若要指定 EMMA 程式代碼涵蓋範圍結果檔案路徑:</b> -e coverageFile /sdcard/myFile.ec <br/>,以及其他自變數。
已取代這個成員。 請改用 AndroidJUnitRunner 。 應該使用 Android測試支持連結庫撰寫新的測試。
的 android.test.InstrumentationTestRunnerJava 檔。
此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。
建構函式
| 名稱 | Description |
|---|---|
| InstrumentationTestRunner() | |
| InstrumentationTestRunner(IntPtr, JniHandleOwnership) |
已淘汰.
建立 JNI 物件的 Managed 表示法時使用的建構函式;由運行時間呼叫。 |
欄位
| 名稱 | Description |
|---|---|
| ReportKeyIdentifier |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態或最終套件組合中,此索引鍵會識別正在寫入報表的類別。 (繼承來源 Instrumentation) |
| ReportKeyNameClass |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態或最終配套中,此索引鍵會識別目前測試類別的名稱。 |
| ReportKeyNameTest |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態或最終套件組合中,則此機碼會識別目前測試的名稱。 |
| ReportKeyNumCurrent |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態或最終套件組合中,此索引鍵會識別目前測試的序號。 |
| ReportKeyNumTotal |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態或最終套件組合中,此機碼會識別正在執行的測試總數。 |
| ReportKeyStack |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態套件組合中,此機碼會識別描述錯誤或失敗的堆疊追蹤。 |
| ReportKeyStreamresult |
已淘汰.
如果包含在傳送至 IInstrumentationWatcher 的狀態或最終套件組合中,此索引鍵會識別一個字元串,而字串可以直接列印至輸出數據流。 (繼承來源 Instrumentation) |
| ReportValueId |
已淘汰.
如果以索引鍵 |
屬性
| 名稱 | Description |
|---|---|
| AllocCounts |
已淘汰.
傳回與配置計數中目前結果的套件組合。 (繼承來源 Instrumentation) |
| Arguments |
已淘汰.
取得傳遞至此檢測的自變數。 |
| BinderCounts |
已淘汰.
傳回此程式之各種系結器計數的套件組合。 (繼承來源 Instrumentation) |
| Class |
已淘汰.
傳回這個 |
| ComponentName |
已淘汰.
傳回此檢測的完整元件名稱。 (繼承來源 Instrumentation) |
| Context |
已淘汰.
傳回此檢測套件的內容。 (繼承來源 Instrumentation) |
| Handle |
已淘汰.
基礎Android實例的句柄。 (繼承來源 Object) |
| IsProfiling |
已淘汰.
檢查是否已啟動此檢測,並啟用程式代碼剖析。 (繼承來源 Instrumentation) |
| JniIdentityHashCode |
已淘汰.
取得由互通執行時指派給此 Java 對等端的身份雜湊碼。 (繼承來源 Object) |
| JniManagedPeerState |
已淘汰.
|
| JniPeerMembers |
已淘汰.
|
| Loader |
已淘汰.
覆寫此選項,以提供封裝類別載入器的訪問許可權。 |
| PeerReference |
已淘汰.
取得這個 Java 節點的 JNI 物件參考。 (繼承來源 Object) |
| ProcessName |
已淘汰.
傳回此檢測正在執行的進程名稱。 (繼承來源 Instrumentation) |
| TargetContext |
已淘汰.
傳回所檢測目標應用程式的內容。 (繼承來源 Instrumentation) |
| ThresholdClass |
已淘汰.
此 API 支援適用於 Android 的 Mono 基礎結構,並不適合直接從您的程式代碼使用。 |
| ThresholdType |
已淘汰.
此 API 支援適用於 Android 的 Mono 基礎結構,並不適合直接從您的程式代碼使用。 |
| UiAutomation |
已淘汰.
|
方法
明確介面實作
| 名稱 | Description |
|---|---|
| IJavaPeerable.Disposed() |
已淘汰.
|
| IJavaPeerable.Finalized() |
已淘汰.
|
| IJavaPeerable.JniObjectReferenceControlBlock |
已淘汰.
|
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
已淘汰.
|
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
已淘汰.
|
| IJavaPeerable.SetPeerReference(JniObjectReference) |
已淘汰.
|
擴充方法
| 名稱 | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
已淘汰.
取得實例 |
| JavaAs<TResult>(IJavaPeerable) |
已淘汰.
試著強制 |
| JavaCast<TResult>(IJavaObject) |
已淘汰.
執行 Android 執行時間檢查的類型轉換。 |
| JavaCast<TResult>(IJavaObject) |
已淘汰.
|
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
已淘汰.
試著強制 |