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=“特殊參考”><h3>開發者指南</h3>
如需應用程式測試的詳細資訊,請參閱 測試 開發人員指南。
</div>
<h3>典型使用<率/h3><ol><li>寫 junit.framework.TestCase入,針對套件中的類別執行單元、功能或效能測試。 這些通常是子分類來源:<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 instrument -w」執行儀器,且不包含可選參數,以執行所有測試(效能測試除外)。
<li>使用「adb shell am instrument -w」執行儀器,並以參數「-e func true」執行所有函數測試。 這些是衍生自 android.test.InstrumentationTestCase的測試。
<li>使用「adb shell am instrument -w」執行儀器,並以參數「-e unit true」執行所有單元測試。 這些測試 不是衍生自 android.test.InstrumentationTestCase 的測試(且不是效能測試)。
<li>使用「adb shell am instrument -w」執行該儀表,並設定參數「-e class」以執行單一 junit.framework.TestCase。
</ol><p/>執行所有測試: adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner <p/>執行所有小型測試: adb shell am instrument -w -e small com.android.foo/android.test.InstrumentationTestRunner <p/>執行所有中等測試: adb shell am instrument -w -e medium com.android.foo/android.test.InstrumentationTestRunner <p/>執行所有大型測試: adb shell am instrument -w -e size 大 com.android.foo/android.test.InstrumentationTestRunner <p/>Filter test run 對指定註解的測試執行: adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner <p/> 若與其他選項一起使用,結果的測試執行將包含兩個選項的聯集。 例如,“-e size large -e annotation com.android.foo.MyAnnotation” 只會使用 LargeTest 和 “com.android.foo.MyAnnotation” 註釋來執行測試。
<p/><b>篩選測試執行至 未 給註解的測試:</b> adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner <p/>執行單一測試案例: adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/android.test.InstrumentationTestRunner <p/>執行單一測試: adb shell am instrument -w -e on class com.android.foo.FooTest#testFoo com.android.foo/android.test.InstrumentationTestRunner <p/>Running multiple tests: adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest p </>以 java 套件執行所有測試: adb shell am instrument -w -e package com.android.foo.subpkg com.android.foo.foo/android.test.InstrumentationTestRunner <p/>包含效能測試: adb shell am instrument -w -e perf true com.android.foo/android.test.InstrumentationTestRunner <p/>若要除錯測試,請在程式碼中設定一個中斷點並傳入: -e debug true <p/>以「僅記錄」模式執行 -e log true 此選項會載入並遍歷所有測試類別與方法,但會跳過實際測試執行。 適用於快速取得檢測命令所要執行之測試的資訊。
<p/>要產生 EMMA 程式碼覆蓋率: -e 覆蓋範圍為真 注意:這需要 emma 儀器化的編譯。 預設情況下,程式碼覆蓋率結果檔會儲存在 /data/<app>/coverage.ec 檔案中,除非被 coverageFile 標誌(見下文) <覆蓋。p/> 若要指定 EMMA 程式碼覆蓋率結果檔案路徑: -e coverageFile /sdcard/myFile.ec <br/> ,以及其他參數。
已取代這個成員。 請改用 AndroidJUnitRunner 。 應該使用 Android測試支持連結庫撰寫新的測試。
Java 文件 android.test.InstrumentationTestRunner。
此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。
建構函式
| 名稱 | Description |
|---|---|
| InstrumentationTestRunner() |
已淘汰.
初始化 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 |
已淘汰.
取得執行時最後指派的狀態旗標。 (繼承來源 JavaObject) |
| JniPeerMembers |
已淘汰.
取得用於存取此 Java 綁定成員的 JNI 元資料。 |
| 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 |
已淘汰.
取得此對等端使用的原生控制區塊指標。 (繼承來源 JavaObject) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
已淘汰.
儲存執行時提供的身份雜湊碼。 (繼承來源 JavaObject) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
已淘汰.
取代儲存的受管理對等狀態旗標。 (繼承來源 JavaObject) |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
已淘汰.
當引用無效時,更新對等節點並釋放已拋棄節點的控制區塊。 (繼承來源 JavaObject) |
擴充方法
| 名稱 | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
已淘汰.
取得實例 |
| JavaAs<TResult>(IJavaPeerable) |
已淘汰.
試著強制 |
| JavaCast<TResult>(IJavaObject) |
已淘汰.
執行 Android 執行時間檢查的類型轉換。 |
| JavaCast<TResult>(IJavaObject) |
已淘汰.
重用相容的受管理對等端或取得請求型態的包裝器。 |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
已淘汰.
試著強制 |