儀器儀表測試
public class InstrumentationTest
extends Object
implements IDeviceTest , IRemoteTest , ITestCollector , IAbiReceiver , IConfigurationReceiver , IMetricCollectorReceiver
java.lang.Object | |
↳ | com.android.tradefed.testtype.InstrumentationTest |
在給定設備上執行儀器測試包的測試。
概括
領域 | |
---|---|
public static final String | RUN_TESTS_AS_USER_KEY |
public static final String | RUN_TESTS_ON_SDK_SANDBOX |
protected boolean | mDebug
|
公共構造函數 | |
---|---|
InstrumentationTest () |
公共方法 | |
---|---|
void | addDeviceListeners ( extraListeners) addDeviceListeners ( extraListeners) 允許向運行器添加更多自訂偵聽器 |
void | addInstrumentationArg (String key, String value) 添加一個參數以在運行儀器測試時提供。 |
IAbi | getAbi () |
IConfiguration | getConfiguration () 取得此測試的 |
String | getCoverageTarget () 取得先前透過 |
boolean | getDebug () 取得儀器調試設定。 |
ITestDevice | getDevice () 獲取被測設備。 |
String | getForceAbi () |
long | getMaxTimeout () 返回為檢測設定的最大逾時。 |
String | getPackageName () 取得要運行的 Android 清單包。 |
String | getRunName () 取得將提供給偵聽器的自訂測試運行名稱 |
String | getRunnerName () 取得要使用的 Android Instrumentation 運行程式。 |
void | run ( TestInformation testInfo, ITestInvocationListener listener) 運行測試,並將結果報告給偵聽器。 |
void | setAbi ( IAbi abi) |
void | setClassName (String testClassName) (可選)設定要執行的測試類別名稱。 |
void | setCollectTestsOnly (boolean shouldCollectTest) 啟用或停用測試收集模式 |
void | setCollectsTestsShellTimeout (int timeout) 此方法已被棄用。該方法是無操作的 |
void | setConfiguration ( IConfiguration config) 注入正在使用的 |
void | setCoverageTarget (String coverageTarget) 設定本次測試的覆蓋率目標。 |
void | setDebug (boolean debug) 設定儀器調試設定。 |
void | setDevice ( ITestDevice device) 注入被測設備。 |
void | setEnforceFormat (boolean enforce) 如果我們強制執行偵測的 AJUR 輸出格式,則設定為 True。 |
void | setForceAbi (String abi) 設定force-abi選項。 |
void | setInstallFile (File installFile) 設定要安裝的包含測試的可選檔案。 |
void | setIsolatedStorage (boolean isolatedStorage) 設定是否使用隔離存儲。 |
void | setMethodName (String testMethodName) (可選)設定要運行的測試方法。 |
void | setMetricCollectors ( collectors) setMetricCollectors ( collectors) 設定為測試運行定義的 |
void | setPackageName (String packageName) 設定要運行的 Android 清單包。 |
void | setReRunUsingTestFile (boolean reRunUsingTestFile) 設定 --rerun-from-file 選項。 |
void | setRerunMode (boolean rerun) (可選)設定重新運轉模式。 |
void | setRunName (String runName) 設定將提供給偵聽器的自訂測試運行名稱 |
void | setRunnerName (String runnerName) (可選)設定要使用的 Android 儀器運行程序。 |
void | setShellTimeout (long timeout) (可選)設定設備期望 shell 輸出的最長時間(以毫秒為單位)。 |
void | setTestFilePathOnDevice (String testFilePathOnDevice) (選用)設定裝置上檔案的路徑,該檔案應包含要執行的行分隔測試類別和方法的清單(格式:com.foo.Class#method)。 |
void | setTestPackageName (String testPackageName) 設定測試包過濾器。 |
void | setTestSize (String size) (可選)設定要運行的測試大小。 |
void | setTestTimeout (long timeout) (可選)設定每個單獨測試運行的最長時間(以毫秒為單位)。 |
void | setTestsToRun ( tests) setTestsToRun ( tests) 設定應由此 InstrumentationTest 執行的測試集合。 |
void | setWindowAnimation (boolean windowAnimation) |
受保護的方法 | |
---|---|
static | excludeNonExecuted ( TestRunResult results) 過濾掉“NOT_EXECUTED”以追蹤需要重新運行的內容。 |
String | getClassName () 取得要運行的類別名稱。 |
ListInstrumentationParser | getListInstrumentationParser () 取得用於解析「pm list Instrumentation」查詢的 |
String | getMethodName () 運行測試方法。 |
String | getTestPackageName () 取得要運行的測試java套件。 |
String | queryRunnerName () 查詢測試運行器要使用的設備。 |
void | setRunnerArgs (IRemoteAndroidTestRunner runner) |
領域
RUN_TESTS_AS_USER_KEY
public static final String RUN_TESTS_AS_USER_KEY
RUN_TESTS_ON_SDK_SANDBOX
public static final String RUN_TESTS_ON_SDK_SANDBOX
偵錯工具
protected boolean mDebug
公共構造函數
儀器儀表測試
public InstrumentationTest ()
公共方法
新增設備監聽器
public void addDeviceListeners (extraListeners)
允許向運行器添加更多自訂偵聽器
參數 | |
---|---|
extraListeners |
添加InstrumentationArg
public void addInstrumentationArg (String key, String value)
添加一個參數以在運行儀器測試時提供。
參數 | |
---|---|
key | String : 參數名稱 |
value | String : 參數值 |
獲取調試資訊
public boolean getDebug ()
取得儀器調試設定。
退貨 | |
---|---|
boolean | 布爾調試設定。 |
獲取力量Abi
public String getForceAbi ()
退貨 | |
---|---|
String |
取得最大超時時間
public long getMaxTimeout ()
返回為檢測設定的最大逾時。
退貨 | |
---|---|
long |
取得包名
public String getPackageName ()
取得要運行的 Android 清單包。
退貨 | |
---|---|
String |
取得運行名稱
public String getRunName ()
取得將提供給偵聽器的自訂測試運行名稱
退貨 | |
---|---|
String |
獲取跑步者姓名
public String getRunnerName ()
取得要使用的 Android Instrumentation 運行程式。
退貨 | |
---|---|
String |
跑步
public void run (TestInformation testInfo, ITestInvocationListener listener)
運行測試,並將結果報告給偵聽器。
參數 | |
---|---|
testInfo | TestInformation : TestInformation 物件包含執行測試的有用資訊。 |
listener | ITestInvocationListener :測試結果的ITestInvocationListener |
投擲 | |
---|---|
DeviceNotAvailableException |
設定類別名稱
public void setClassName (String testClassName)
(可選)設定要執行的測試類別名稱。
參數 | |
---|---|
testClassName | String |
僅設定收集測試
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或停用測試收集模式
setCollectsTestsShellTimeout
public void setCollectsTestsShellTimeout (int timeout)
此方法已被棄用。
該方法是無操作的
設定最大時間(以毫秒為單位),以在收集測試時允許「shell 輸出回應的最大時間」。
參數 | |
---|---|
timeout | int |
設定配置
public void setConfiguration (IConfiguration config)
注入正在使用的IConfiguration
。
參數 | |
---|---|
config | IConfiguration |
設定覆蓋目標
public void setCoverageTarget (String coverageTarget)
設定本次測試的覆蓋率目標。
目前未使用。此方法只是存在,因此以後可以透過getCoverageTarget()
檢索coverageTarget
參數 | |
---|---|
coverageTarget | String |
設定調試
public void setDebug (boolean debug)
設定儀器調試設定。
參數 | |
---|---|
debug | boolean :用於設定儀器調試設定的布林值。 |
設定強制格式
public void setEnforceFormat (boolean enforce)
如果我們強制執行偵測的 AJUR 輸出格式,則設定為 True。
參數 | |
---|---|
enforce | boolean |
設定強制Abi
public void setForceAbi (String abi)
設定force-abi選項。
設定安裝文件
public void setInstallFile (File installFile)
設定要安裝的包含測試的可選檔案。
參數 | |
---|---|
installFile | File :可安裝ERROR(/File) |
設定隔離存儲
public void setIsolatedStorage (boolean isolatedStorage)
設定是否使用隔離儲存。
參數 | |
---|---|
isolatedStorage | boolean |
設定方法名
public void setMethodName (String testMethodName)
(可選)設定要運行的測試方法。
參數 | |
---|---|
testMethodName | String |
設定MetricCollectors
public void setMetricCollectors (collectors)
設定為測試運行定義的IMetricCollector
清單。
參數 | |
---|---|
collectors |
設定包名
public void setPackageName (String packageName)
設定要運行的 Android 清單包。
參數 | |
---|---|
packageName | String |
設定重新運行使用測試文件
public void setReRunUsingTestFile (boolean reRunUsingTestFile)
設定 --rerun-from-file 選項。
參數 | |
---|---|
reRunUsingTestFile | boolean |
設定重新運行模式
public void setRerunMode (boolean rerun)
(可選)設定重新運轉模式。
參數 | |
---|---|
rerun | boolean |
設定運行名稱
public void setRunName (String runName)
設定將提供給偵聽器的自訂測試運行名稱
參數 | |
---|---|
runName | String |
設定跑步者名稱
public void setRunnerName (String runnerName)
(可選)設定要使用的 Android 儀器運行程序。
參數 | |
---|---|
runnerName | String |
設定Shell超時
public void setShellTimeout (long timeout)
(可選)設定設備期望 shell 輸出的最長時間(以毫秒為單位)。
參數 | |
---|---|
timeout | long |
在裝置上設定測試檔案路徑
public void setTestFilePathOnDevice (String testFilePathOnDevice)
(選用)設定裝置上檔案的路徑,該檔案應包含要執行的行分隔測試類別和方法的清單(格式:com.foo.Class#method)。如果設置,將自動嘗試透過 InstrumentationFileTest 使用此測試檔案重新執行測試,而不是透過重新執行為每個剩餘測試執行單獨的 adb 命令。
參數 | |
---|---|
testFilePathOnDevice | String |
設定測試包名稱
public void setTestPackageName (String testPackageName)
設定測試包過濾器。
如果非 null,則僅執行給定 java 套件內的測試。
如果為setClassName(String)
提供了非空值,則會被忽略
參數 | |
---|---|
testPackageName | String |
設定測試大小
public void setTestSize (String size)
(可選)設定要運行的測試大小。
參數 | |
---|---|
size | String |
設定測試超時
public void setTestTimeout (long timeout)
(可選)設定每個單獨測試運行的最長時間(以毫秒為單位)。
參數 | |
---|---|
timeout | long |
設定要運行的測試
public void setTestsToRun (tests)
設定應由此 InstrumentationTest 執行的測試集合。
參數 | |
---|---|
tests |
設定視窗動畫
public void setWindowAnimation (boolean windowAnimation)
參數 | |
---|---|
windowAnimation | boolean |
受保護的方法
排除未執行
protected staticexcludeNonExecuted (TestRunResult results)
過濾掉“NOT_EXECUTED”以追蹤需要重新運行的內容。
參數 | |
---|---|
results | TestRunResult |
退貨 | |
---|---|
取得類別名
protected String getClassName ()
取得要運行的類別名稱。
退貨 | |
---|---|
String |
取得ListInstrumentationParser
protected ListInstrumentationParser getListInstrumentationParser ()
取得用於解析「pm list Instrumentation」查詢的ListInstrumentationParser
。
退貨 | |
---|---|
ListInstrumentationParser |
取得方法名
protected String getMethodName ()
運行測試方法。
退貨 | |
---|---|
String |
取得測試包名稱
protected String getTestPackageName ()
取得要運行的測試java套件。
退貨 | |
---|---|
String |
查詢運行者名稱
protected String queryRunnerName ()
查詢測試運行器要使用的設備。
退貨 | |
---|---|
String | 與套件相符的第一個測試運行程序名稱,如果找不到任何名稱,則傳回 null。 |
投擲 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
設置RunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
參數 | |
---|---|
runner | IRemoteAndroidTestRunner |