InstrumentationTest

public class InstrumentationTest
extends Object implements IAbiReceiver, IConfigurationReceiver, IDeviceTest, IMetricCollectorReceiver, IRemoteTest, ITestCollector

java.lang.Object
   ↳ com.android.tradefed.testtype.InstrumentationTest


這項測試會在指定裝置上執行檢測設備測試套件。

摘要

常數

String RUN_TESTS_AS_USER_KEY

String RUN_TESTS_ON_SDK_SANDBOX

欄位

protected boolean mDebug

protected boolean mInstrumentSdkInSandbox

protected boolean mInstrumentSdkSandbox

公用建構函式

InstrumentationTest()

公用方法

void addDeviceListeners( extraListeners)

允許在執行器中新增更多自訂事件監聽器

void addInstrumentationArg(String key, String value)

新增引數,在執行檢測設備測試時提供。

IAbi getAbi()
IConfiguration getConfiguration()

取得這項測試的 IConfiguration

String getCoverageTarget()

取得先前透過 setCoverageTarget(String) 設定的 coverageTarget。

boolean getDebug()

取得插樁偵錯設定。

ITestDevice getDevice()

取得受測裝置。

String getForceAbi()
long getMaxTimeout()

傳回為插樁設定的逾時時間上限。

String getPackageName()

取得要執行的 Android 資訊清單套件。

String getRunName()

取得將提供給接聽程式的自訂測試執行名稱

String getRunnerName()

Gets the Android instrumentation runner to be used.

boolean isOrchestrator()

傳回 ERROR(InstrumentationTest.mOrchestrator/com.android.tradefed.testtype.InstrumentationTest#mOrchestrator InstrumentationTest.mOrchestrator) 的值

void run(TestInformation testInfo, ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setAbi(IAbi abi)
void setClassName(String testClassName)

(選用) 設定要執行的測試類別名稱。

void setCollectTestsOnly(boolean shouldCollectTest)

啟用或停用測試收集模式

void setCollectsTestsShellTimeout(int timeout)

這個方法已淘汰。 這個方法是無運算

void setConfiguration(IConfiguration config)

注入使用的 IConfiguration

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)

設定是否使用隔離儲存空間。

void setMethodName(String testMethodName)

您可以視需要設定要執行的測試方法。

void setMetricCollectors( collectors)

設定為測試執行作業定義的 IMetricCollector 清單。

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( tests)

設定應由這個 InstrumentationTest 執行的測試集合。

void setWindowAnimation(boolean windowAnimation)

受保護的方法

static excludeNonExecuted(TestRunResult results)

篩除「NOT_EXECUTED」和「Skipped」,追蹤需要重新執行的項目。

String getClassName()

取得要執行的類別名稱。

ListInstrumentationParser getListInstrumentationParser()

取得用於剖析「pm list instrumentation」查詢的 ListInstrumentationParser

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_AS_USER"

RUN_TESTS_ON_SDK_SANDBOX

public static final String RUN_TESTS_ON_SDK_SANDBOX

常數值: "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:引數值

getAbi

public IAbi getAbi ()

傳回
IAbi

getConfiguration

public IConfiguration getConfiguration ()

取得這項測試的 IConfiguration

傳回
IConfiguration

getCoverageTarget

public String getCoverageTarget ()

取得先前透過 setCoverageTarget(String) 設定的 coverageTarget。

傳回
String

getDebug

public boolean getDebug ()

取得插樁偵錯設定。

傳回
boolean 布林值偵錯設定。

getDevice

public ITestDevice getDevice ()

取得受測裝置。

傳回
ITestDevice ITestDevice

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

得分

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

執行測試,並向接聽程式回報結果。

參數
testInfo TestInformation:包含執行測試的實用資訊的 TestInformation 物件。

listener ITestInvocationListener:測試結果的 ITestInvocationListener

擲回
DeviceNotAvailableException

setAbi

public void setAbi (IAbi abi)

參數
abi IAbi

setClassName

public void setClassName (String testClassName)

(選用) 設定要執行的測試類別名稱。

參數
testClassName String

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

啟用或停用測試收集模式

setCollectsTestsShellTimeout

public void setCollectsTestsShellTimeout (int timeout)

這個方法已淘汰。
這個方法是無運算

設定收集測試時,允許「殼層輸出回應時間上限」的最大時間 (以毫秒為單位)。

參數
timeout int

setConfiguration

public void setConfiguration (IConfiguration config)

插入使用的 IConfiguration

參數
config IConfiguration

setCoverageTarget

public void setCoverageTarget (String coverageTarget)

設定這項測試的涵蓋範圍目標。

目前未使用。這個方法只是為了稍後透過 getCoverageTarget() 擷取 coverageTarget 而存在。

參數
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)

設定是否使用隔離儲存空間。

參數
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 static  excludeNonExecuted (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