InstrumentationTest
public
class
InstrumentationTest
extends Object
implements
IAbiReceiver,
IConfigurationReceiver,
IDeviceTest,
IMetricCollectorReceiver,
IRemoteTest,
ITestCollector
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
|
protected
boolean |
mInstrumentSdkInSandbox
|
protected
boolean |
mInstrumentSdkSandbox
|
公用建構函式 | |
---|---|
InstrumentationTest()
|
公用方法 | |
---|---|
void
|
addDeviceListeners(
允許在執行程式中新增更多自訂事件監聽器 |
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 檢測執行程式。 |
boolean
|
isOrchestrator()
|
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)
設定強制 ABI 選項。 |
void
|
setInstallFile(File installFile)
設定要安裝的選用檔案,其中包含測試。 |
void
|
setIsolatedStorage(boolean isolatedStorage)
設定是否要使用 Isolated Storage。 |
void
|
setMethodName(String testMethodName)
您可以選擇設定要執行的測試方法。 |
void
|
setMetricCollectors(
設定為測試執行作業定義的 |
void
|
setOrchestrator(boolean useOrchestrator)
設定 --orchestrator 選項 |
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)
您可以選擇設定裝置的殼層輸出作業的時間上限 (以毫秒為單位)。 |
void
|
setTestFilePathOnDevice(String testFilePathOnDevice)
您可以選擇設定裝置上檔案的路徑,該檔案應包含要執行的測試類別和方法 (格式:com.foo.Class#method) 清單。 |
void
|
setTestPackageName(String testPackageName)
設定測試套件篩選器。 |
void
|
setTestSize(String size)
您也可以選擇設定要執行的測試大小。 |
void
|
setTestTimeout(long timeout)
您可以視需要為每個個別測試執行作業設定時間上限 (以毫秒為單位)。 |
void
|
setTestsToRun(
設定這個檢測設備測試應執行的測試集合。 |
void
|
setWindowAnimation(boolean windowAnimation)
|
受保護的方法 | |
---|---|
static
|
excludeNonExecuted(TestRunResult results)
篩除「NOT_EXECUTED」和「Skipped」,以便追蹤需要重新執行的項目。 |
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
mDebug
protected boolean mDebug
mInstrumentSdkInSandbox
protected boolean mInstrumentSdkInSandbox
mInstrumentSdkSandbox
protected boolean mInstrumentSdkSandbox
公用建構函式
InstrumentationTest
public InstrumentationTest ()
公用方法
addDeviceListeners
public void addDeviceListeners (extraListeners)
允許在執行程式中新增更多自訂事件監聽器
參數 | |
---|---|
extraListeners |
|
addInstrumentationArg
public void addInstrumentationArg (String key, String value)
新增要在執行檢測設備測試時提供的引數。
參數 | |
---|---|
key |
String :引數名稱 |
value |
String :引數值 |
getConfiguration
public IConfiguration getConfiguration ()
取得這項測試的 IConfiguration
。
傳回 | |
---|---|
IConfiguration |
getCoverageTarget
public String getCoverageTarget ()
透過 setCoverageTarget(String)
取得先前設定的 coverageTarget。
傳回 | |
---|---|
String |
getDebug
public boolean getDebug ()
取得檢測偵錯設定。
傳回 | |
---|---|
boolean |
布林值偵錯設定。 |
getForceAbi
public String getForceAbi ()
傳回 | |
---|---|
String |
getMaxTimeout
public long getMaxTimeout ()
傳回為評估工具設定的逾時上限。
傳回 | |
---|---|
long |
getPackageName
public String getPackageName ()
取得要執行的 Android 資訊清單套件。
傳回 | |
---|---|
String |
getRunName
public String getRunName ()
取得要提供給事件監聽器的自訂測試執行名稱
傳回 | |
---|---|
String |
getRunnerName
public String getRunnerName ()
取得要使用的 Android 檢測執行工具。
傳回 | |
---|---|
String |
isOrchestrator
public boolean isOrchestrator ()
傳回 | |
---|---|
boolean |
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
執行測試,並將結果回報給監聽器。
參數 | |
---|---|
testInfo |
TestInformation :包含執行測試所需實用資訊的 TestInformation 物件。 |
listener |
ITestInvocationListener :測試結果的 ITestInvocationListener |
擲回 | |
---|---|
DeviceNotAvailableException |
setClassName
public void setClassName (String testClassName)
視需要設定要執行的測試類別名稱。
參數 | |
---|---|
testClassName |
String |
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或停用測試收集模式
setCollectsTestsShellTimeout
public void setCollectsTestsShellTimeout (int timeout)
This method is deprecated.
這個方法是無操作
設定以毫秒為單位的時間上限,以便在收集測試時允許「殼層輸出回應的最大時間」。
參數 | |
---|---|
timeout |
int |
setConfiguration
public void setConfiguration (IConfiguration config)
插入正在使用的 IConfiguration
。
參數 | |
---|---|
config |
IConfiguration |
setCoverageTarget
public void setCoverageTarget (String coverageTarget)
設定此測試的涵蓋率目標。
目前未使用。這個方法只是為了讓 coverageTarget 日後可透過 getCoverageTarget()
擷取
參數 | |
---|---|
coverageTarget |
String |
setDebug
public void setDebug (boolean debug)
設定檢測工具偵錯設定。
參數 | |
---|---|
debug |
boolean :要將檢測工具偵錯設定設為的布林值。 |
setDevice
public void setDevice (ITestDevice device)
插入測試中的裝置。
參數 | |
---|---|
device |
ITestDevice :要使用的 ITestDevice |
setEnforceFormat
public void setEnforceFormat (boolean enforce)
如果我們強制執行檢測工具的 AJUR 輸出格式,請將此值設為 True。
參數 | |
---|---|
enforce |
boolean |
setForceAbi
public void setForceAbi (String abi)
設定強制 ABI 選項。
setInstallFile
public void setInstallFile (File installFile)
設定要安裝的選用檔案,其中包含測試。
參數 | |
---|---|
installFile |
File :可安裝的 ERROR(/File) |
setIsolatedStorage
public void setIsolatedStorage (boolean isolatedStorage)
設定是否要使用 Isolated Storage。
參數 | |
---|---|
isolatedStorage |
boolean |
setMethodName
public void setMethodName (String testMethodName)
您可以選擇設定要執行的測試方法。
參數 | |
---|---|
testMethodName |
String |
setMetricCollectors
public void setMetricCollectors (collectors)
設定為測試執行作業定義的 IMetricCollector
清單。
參數 | |
---|---|
collectors |
|
setOrchestrator
public void setOrchestrator (boolean useOrchestrator)
設定 --orchestrator 選項
參數 | |
---|---|
useOrchestrator |
boolean |
setPackageName
public void setPackageName (String packageName)
設定要執行的 Android 資訊清單套件。
參數 | |
---|---|
packageName |
String |
setReRunUsingTestFile
public void setReRunUsingTestFile (boolean reRunUsingTestFile)
設定 --rerun-from-file 選項。
參數 | |
---|---|
reRunUsingTestFile |
boolean |
setRerunMode
public void setRerunMode (boolean rerun)
您可以視需要設定重播模式。
參數 | |
---|---|
rerun |
boolean |
setRunName
public void setRunName (String runName)
設定要提供給監聽者的自訂測試執行名稱
參數 | |
---|---|
runName |
String |
setRunnerName
public void setRunnerName (String runnerName)
您可以視需要設定要使用的 Android 檢測執行程式。
參數 | |
---|---|
runnerName |
String |
setShellTimeout
public void setShellTimeout (long timeout)
您可以選擇設定裝置的殼層輸出內容的時間上限 (以毫秒為單位)。
參數 | |
---|---|
timeout |
long |
setTestFilePathOnDevice
public void setTestFilePathOnDevice (String testFilePathOnDevice)
您可以選擇設定裝置上檔案的路徑,該檔案應包含要執行的測試類別和方法 (格式:com.foo.Class#method) 清單。如果已設定,系統會自動嘗試透過 InstrumentationFileTest 使用此測試檔案重新執行測試,而非透過重新執行作業,針對每個剩餘的測試執行個別的 ADB 指令。
參數 | |
---|---|
testFilePathOnDevice |
String |
setTestPackageName
public void setTestPackageName (String testPackageName)
設定測試套件篩選器。
如果不為空值,則只會執行指定 Java 套件中的測試。
如果已向 setClassName(String)
提供非空值,系統會忽略
參數 | |
---|---|
testPackageName |
String |
setTestSize
public void setTestSize (String size)
您也可以選擇設定要執行的測試大小。
參數 | |
---|---|
size |
String |
setTestTimeout
public void setTestTimeout (long timeout)
您可以視需要設定個別測試執行的時間上限 (以毫秒為單位)。
參數 | |
---|---|
timeout |
long |
setTestsToRun
public void setTestsToRun (tests)
設定這個 InstrumentationTest 應執行的測試集合。
參數 | |
---|---|
tests |
:要執行的測試 |
setWindowAnimation
public void setWindowAnimation (boolean windowAnimation)
參數 | |
---|---|
windowAnimation |
boolean |
受保護的方法
excludeNonExecuted
protected staticexcludeNonExecuted (TestRunResult results)
篩除「NOT_EXECUTED」和「Skipped」,以便追蹤需要重新執行的項目。
參數 | |
---|---|
results |
TestRunResult |
傳回 | |
---|---|
|
getClassName
protected String getClassName ()
取得要執行的類別名稱。
傳回 | |
---|---|
String |
getListInstrumentationParser
protected ListInstrumentationParser getListInstrumentationParser ()
取得用於剖析「pm list instrumentation」查詢的 ListInstrumentationParser
。
傳回 | |
---|---|
ListInstrumentationParser |
getMethodName
protected String getMethodName ()
取得要執行的測試方法。
傳回 | |
---|---|
String |
getTestPackageName
protected String getTestPackageName ()
取得要執行的測試 Java 套件。
傳回 | |
---|---|
String |
queryRunnerName
protected String queryRunnerName ()
查詢裝置,供測試執行工具使用。
傳回 | |
---|---|
String |
與套件相符的第一個測試執行工具名稱,如果找不到則為空值。 |
擲回 | |
---|---|
|
com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
setRunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
參數 | |
---|---|
runner |
IRemoteAndroidTestRunner |